spring boot 极光推送

1、引入Maven

      <!--极光短信包-->
        <!-- https://mvnrepository.com/artifact/cn.jpush.api/jiguang-common -->
        <dependency>
            <groupId>cn.jpush.api</groupId>
            <artifactId>jiguang-common</artifactId>
            <version>1.2.0</version>
        </dependency>
        <!--极光短信包-->
        <!-- https://mvnrepository.com/artifact/cn.jpush.api/jsms-client -->
        <dependency>
            <groupId>cn.jpush.api</groupId>
            <artifactId>jsms-client</artifactId>
            <version>1.2.10</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/cn.jpush.api/jpush-client -->
        <dependency>
            <groupId>cn.jpush.api</groupId>
            <artifactId>jpush-client</artifactId>
            <version>3.6.3</version>
        </dependency>

2、 极光推送接口测试

 @Test
    public void sendMsg() {
        //https://www.jiguang.cn/portal/#/dev/sdkIntegration/a1ffab96b1224587b3f2947c/android
        final String phoneNumber = "1871637xxxx";
        //46f7f8c30a3b10f85a6a62f7bb53f29b
        //发送短信
        SMSClient client = new SMSClient(SmsConfig.masterSecret, SmsConfig.apikey);
        //46f7f8c30a3b10f85a6a62f7bb53f29b
        SMSPayload payload = SMSPayload.newBuilder()//
                .setSignId(SmsConfig.singId)//
                .setMobileNumber(phoneNumber).setTempId(SmsConfig.tempId)//对第3方系统的
                .addTempPara("code", "666777").build();
        try {
            SendSMSResult res = client.sendTemplateSMS(payload);
            System.out.println(res.toString());
        } catch (APIRequestException e) {
            e.printStackTrace();
        } catch (APIConnectionException e) {
            e.printStackTrace();
        }

    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Spring Boot中使用极光推送服务,你需要进行以下几个步骤。 1. 首先,你需要在极光官网(https://www.jiguang.cn/)进行注册并开通极光推送服务。 2. 然后,在你的Spring Boot程序中,创建一个yml配置文件,用于配置推送服务的相关信息。 3. 在程序中引入极光推送的服务类,并注入到需要使用的地方。你可以使用@Autowired注解将JiGuangPushService注入到你的控制器中。 4. 如果你想进行广播推送,即给所有拥有你的app下载安装的用户发送推送消息,你可以使用pushAll方法。该方法接收推送标题和内容作为参数,并返回一个布尔值表示推送是否成功。 5. 如果你想进行单点推送,即给指定的用户发送推送消息,你可以使用push方法。该方法接收推送标题、设备对应的唯一极光ID(regId)和推送内容作为参数,并返回一个布尔值表示推送是否成功。 通过以上步骤,你可以在Spring Boot中使用极光推送服务来发送推送消息。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [【SpringBoot】在SpringBoot中如何使用 极光推送](https://blog.csdn.net/peng_YuJun/article/details/130163389)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [SpringBoot整合极光推送](https://blog.csdn.net/qq_39252591/article/details/105224791)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值