最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringBoot集成極光推送的實現代碼

 更新時間:2023年08月09日 14:40:09   作者:oh LAN  
工作中經常會遇到服務器向App推送消息的需求,一般企業(yè)中選擇用極光推送的比較多,本文就介紹了SpringBoot集成極光推送的實現代碼,感興趣的可以了解一下

工作中經常會遇到服務器向App推送消息的需求,一般企業(yè)中選擇用極光推送的比較多,在集成極光時發(fā)現極光的文檔并不完整,網上的文章也很多不能直接使用,這里列出我在工作中集成極光的全部代碼,只需要按照如下代碼保證一次性實現。

1.pom.xml

<!-- 極光推送 begin -->
<dependency>
    <groupId>cn.jpush.api</groupId>
    <artifactId>jpush-client</artifactId>
    <version>3.3.10</version>
</dependency>
<dependency>
    <groupId>cn.jpush.api</groupId>
    <artifactId>jiguang-common</artifactId>
    <version>1.1.4</version>
</dependency>
<!-- 極光推送 end -->

2.application.yml

jpush:
  appKey: xxx
  masterSecret: xxxx
  apnsProduction: false   # 是否生成環(huán)境,true表示生成環(huán)境

3.MyJPushClient

import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.Message;
import cn.jpush.api.push.model.Options;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.IosNotification;
import cn.jpush.api.push.model.notification.Notification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * 極光推送客戶端
 *
 * @author Mengday Zhang
 * @version 1.0
 * @since 2019-04-01
 */
@Component
public class MyJPushClient {
/* @Value("${jpush.appKey}")
    private String appKey;
    @Value("${jpush.masterSecret}")
    private String masterSecret; 
    @Value("${jpush.apnsProduction}")
    private boolean apnsProduction;
*/
    // main 測試直接寫死
    public static String appKey="應用appkey";
    public static   String masterSecret="應用Secret";
    public static  boolean apnsProduction=false;
    private static JPushClient jPushClient = null;
    private static final int RESPONSE_OK = 200;
    private static final Logger logger = LoggerFactory.getLogger(MyJPushClient.class);
    public JPushClient getJPushClient() {
        if (jPushClient == null) {
            jPushClient = new JPushClient(masterSecret, appKey);
        }
        return jPushClient;
    }
    /**
     * 推送到alias列表
     *
     * @param alias             別名或別名組
     * @param notificationTitle 通知內容標題
     * @param msgTitle          消息內容標題
     * @param msgContent        消息內容
     * @param extras            擴展字段
     */
    public void sendToAliasList(List<String> alias, String notificationTitle, String msgTitle, String msgContent, String extras) {
        PushPayload pushPayload = buildPushObject_all_aliasList_alertWithTitle(alias, notificationTitle, msgTitle, msgContent, extras);
        this.sendPush(pushPayload);
    }
    /**
     * 推送到tag列表
     *
     * @param tagsList          Tag或Tag組
     * @param notificationTitle 通知內容標題
     * @param msgTitle          消息內容標題
     * @param msgContent        消息內容
     * @param extras            擴展字段
     */
    public void sendToTagsList(List<String> tagsList, String notificationTitle, String msgTitle, String msgContent, String extras) {
        PushPayload pushPayload = buildPushObject_all_tagList_alertWithTitle(tagsList, notificationTitle, msgTitle, msgContent, extras);
        this.sendPush(pushPayload);
    }
    /**
     * 發(fā)送給所有安卓用戶
     *
     * @param notificationTitle 通知內容標題
     * @param msgTitle          消息內容標題
     * @param msgContent        消息內容
     * @param extras        擴展字段
     */
    public void sendToAllAndroid(String notificationTitle, String msgTitle, String msgContent, String extras) {
        PushPayload pushPayload = buildPushObject_android_all_alertWithTitle(notificationTitle, msgTitle, msgContent, extras);
        this.sendPush(pushPayload);
    }
    /**
     * 發(fā)送給所有IOS用戶
     *
     * @param notificationTitle 通知內容標題
     * @param msgTitle          消息內容標題
     * @param msgContent        消息內容
     * @param extras        擴展字段
     */
    public void sendToAllIOS(String notificationTitle, String msgTitle, String msgContent, String extras) {
        PushPayload pushPayload = buildPushObject_ios_all_alertWithTitle(notificationTitle, msgTitle, msgContent, extras);
        this.sendPush(pushPayload);
    }
    /**
     * 發(fā)送給所有用戶
     *
     * @param notificationTitle 通知內容標題
     * @param msgTitle          消息內容標題
     * @param msgContent        消息內容
     * @param extras        擴展字段
     */
    public void sendToAll(String notificationTitle, String msgTitle, String msgContent, String extras) {
        PushPayload pushPayload = buildPushObject_android_and_ios(notificationTitle, msgTitle, msgContent, extras);
        this.sendPush(pushPayload);
    }
    private PushResult sendPush(PushPayload pushPayload) {
        logger.info("pushPayload={}", pushPayload);
        PushResult pushResult = null;
        try {
            pushResult = this.getJPushClient().sendPush(pushPayload);
            logger.info("" + pushResult);
            if (pushResult.getResponseCode() == RESPONSE_OK) {
                logger.info("push successful, pushPayload={}", pushPayload);
            }
        } catch (APIConnectionException e) {
            logger.error("push failed: pushPayload={}, exception={}", pushPayload, e);
        } catch (APIRequestException e) {
            logger.error("push failed: pushPayload={}, exception={}", pushPayload, e);
        }
        return pushResult;
    }
    /**
     * 向所有平臺所有用戶推送消息
     *
     * @param notificationTitle
     * @param msgTitle
     * @param msgContent
     * @param extras
     * @return
     */
    public PushPayload buildPushObject_android_and_ios(String notificationTitle, String msgTitle, String msgContent, String extras) {
        return PushPayload.newBuilder()
                .setPlatform(Platform.android_ios())
                .setAudience(Audience.all())
                .setNotification(Notification.newBuilder()
                        .setAlert(notificationTitle)
                        .addPlatformNotification(AndroidNotification.newBuilder()
                                .setAlert(notificationTitle)
                                .setTitle(notificationTitle)
                                // 此字段為透傳字段,不會顯示在通知欄。用戶可以通過此字段來做一些定制需求,如特定的key傳要指定跳轉的頁面(value)
                                .addExtra("androidNotification extras key", extras)
                                .build()
                        )
                        .addPlatformNotification(IosNotification.newBuilder()
                                // 傳一個IosAlert對象,指定apns title、title、subtitle等
                                .setAlert(notificationTitle)
                                // 直接傳alert
                                // 此項是指定此推送的badge自動加1
                                .incrBadge(1)
                                // 此字段的值default表示系統(tǒng)默認聲音;傳sound.caf表示此推送以項目里面打包的sound.caf聲音來提醒,
                                // 如果系統(tǒng)沒有此音頻則以系統(tǒng)默認聲音提醒;此字段如果傳空字符串,iOS9及以上的系統(tǒng)是無聲音提醒,以下的系統(tǒng)是默認聲音
                                .setSound("default")
                                // 此字段為透傳字段,不會顯示在通知欄。用戶可以通過此字段來做一些定制需求,如特定的key傳要指定跳轉的頁面(value)
                                .addExtra("iosNotification extras key", extras)
                                // 此項說明此推送是一個background推送,想了解background看:http://docs.jpush.io/client/ios_tutorials/#ios-7-background-remote-notification
                                // .setContentAvailable(true)
                                .build()
                        )
                        .build()
                )
                // Platform指定了哪些平臺就會像指定平臺中符合推送條件的設備進行推送。jpush的自定義消息,
                // sdk默認不做任何處理,不會有通知提示。建議看文檔http://docs.jpush.io/guideline/faq/的
                // [通知與自定義消息有什么區(qū)別?]了解通知和自定義消息的區(qū)別
                .setMessage(Message.newBuilder()
                        .setMsgContent(msgContent)
                        .setTitle(msgTitle)
                        .addExtra("message extras key", extras)
                        .build())
                .setOptions(Options.newBuilder()
                        // 此字段的值是用來指定本推送要推送的apns環(huán)境,false表示開發(fā),true表示生產;對android和自定義消息無意義
                        .setApnsProduction(apnsProduction)
                        // 此字段是給開發(fā)者自己給推送編號,方便推送者分辨推送記錄
                        .setSendno(1)
                        // 此字段的值是用來指定本推送的離線保存時長,如果不傳此字段則默認保存一天,最多指定保留十天,單位為秒
                        .setTimeToLive(86400)
                        .build())
                .build();
    }
    /**
     * 向所有平臺單個或多個指定別名用戶推送消息
     *
     * @param aliasList
     * @param notificationTitle
     * @param msgTitle
     * @param msgContent
     * @param extras
     * @return
     */
    private PushPayload buildPushObject_all_aliasList_alertWithTitle(List<String> aliasList, String notificationTitle, String msgTitle, String msgContent, String extras) {
        // 創(chuàng)建一個IosAlert對象,可指定APNs的alert、title等字段
        // IosAlert iosAlert =  IosAlert.newBuilder().setTitleAndBody("title", "alert body").build();
        return PushPayload.newBuilder()
                // 指定要推送的平臺,all代表當前應用配置了的所有平臺,也可以傳android等具體平臺
                .setPlatform(Platform.all())
                // 指定推送的接收對象,all代表所有人,也可以指定已經設置成功的tag或alias或該應應用客戶端調用接口獲取到的registration id
                .setAudience(Audience.alias(aliasList))
                // jpush的通知,android的由jpush直接下發(fā),iOS的由apns服務器下發(fā),Winphone的由mpns下發(fā)
                .setNotification(Notification.newBuilder()
                        // 指定當前推送的android通知
                        .addPlatformNotification(AndroidNotification.newBuilder()
                                .setAlert(notificationTitle)
                                .setTitle(notificationTitle)
                                // 此字段為透傳字段,不會顯示在通知欄。用戶可以通過此字段來做一些定制需求,如特定的key傳要指定跳轉的頁面(value)
                                .addExtra("androidNotification extras key", extras)
                                .build())
                        // 指定當前推送的iOS通知
                        .addPlatformNotification(IosNotification.newBuilder()
                                // 傳一個IosAlert對象,指定apns title、title、subtitle等
                                .setAlert(notificationTitle)
                                // 直接傳alert
                                // 此項是指定此推送的badge自動加1
                                .incrBadge(1)
                                // 此字段的值default表示系統(tǒng)默認聲音;傳sound.caf表示此推送以項目里面打包的sound.caf聲音來提醒,
                                // 如果系統(tǒng)沒有此音頻則以系統(tǒng)默認聲音提醒;此字段如果傳空字符串,iOS9及以上的系統(tǒng)是無聲音提醒,以下的系統(tǒng)是默認聲音
                                .setSound("default")
                                // 此字段為透傳字段,不會顯示在通知欄。用戶可以通過此字段來做一些定制需求,如特定的key傳要指定跳轉的頁面(value)
                                .addExtra("iosNotification extras key", extras)
                                // 此項說明此推送是一個background推送,想了解background看:http://docs.jpush.io/client/ios_tutorials/#ios-7-background-remote-notification
                                // 取消此注釋,消息推送時ios將無法在鎖屏情況接收
                                // .setContentAvailable(true)
                                .build())
                        .build())
                // Platform指定了哪些平臺就會像指定平臺中符合推送條件的設備進行推送。jpush的自定義消息,
                // sdk默認不做任何處理,不會有通知提示。建議看文檔http://docs.jpush.io/guideline/faq/的
                // [通知與自定義消息有什么區(qū)別?]了解通知和自定義消息的區(qū)別
                .setMessage(Message.newBuilder()
                        .setMsgContent(msgContent)
                        .setTitle(msgTitle)
                        .addExtra("message extras key", extras)
                        .build())
                .setOptions(Options.newBuilder()
                        // 此字段的值是用來指定本推送要推送的apns環(huán)境,false表示開發(fā),true表示生產;對android和自定義消息無意義
                        .setApnsProduction(apnsProduction)
                        // 此字段是給開發(fā)者自己給推送編號,方便推送者分辨推送記錄
                        .setSendno(1)
                        // 此字段的值是用來指定本推送的離線保存時長,如果不傳此字段則默認保存一天,最多指定保留十天;
                        .setTimeToLive(86400)
                        .build())
                .build();
    }
    /**
     * 向所有平臺單個或多個指定Tag用戶推送消息
     *
     * @param tagsList
     * @param notificationTitle
     * @param msgTitle
     * @param msgContent
     * @param extras
     * @return
     */
    private PushPayload buildPushObject_all_tagList_alertWithTitle(List<String> tagsList, String notificationTitle, String msgTitle, String msgContent, String extras) {
        //創(chuàng)建一個IosAlert對象,可指定APNs的alert、title等字段
        //IosAlert iosAlert =  IosAlert.newBuilder().setTitleAndBody("title", "alert body").build();
        return PushPayload.newBuilder()
                // 指定要推送的平臺,all代表當前應用配置了的所有平臺,也可以傳android等具體平臺
                .setPlatform(Platform.all())
                // 指定推送的接收對象,all代表所有人,也可以指定已經設置成功的tag或alias或該應應用客戶端調用接口獲取到的registration id
                .setAudience(Audience.tag(tagsList))
                // jpush的通知,android的由jpush直接下發(fā),iOS的由apns服務器下發(fā),Winphone的由mpns下發(fā)
                .setNotification(Notification.newBuilder()
                        // 指定當前推送的android通知
                        .addPlatformNotification(AndroidNotification.newBuilder()
                                .setAlert(notificationTitle)
                                .setTitle(notificationTitle)
                                //此字段為透傳字段,不會顯示在通知欄。用戶可以通過此字段來做一些定制需求,如特定的key傳要指定跳轉的頁面(value)
                                .addExtra("androidNotification extras key", extras)
                                .build())
                        // 指定當前推送的iOS通知
                        .addPlatformNotification(IosNotification.newBuilder()
                                // 傳一個IosAlert對象,指定apns title、title、subtitle等
                                .setAlert(notificationTitle)
                                // 直接傳alert
                                // 此項是指定此推送的badge自動加1
                                .incrBadge(1)
                                // 此字段的值default表示系統(tǒng)默認聲音;傳sound.caf表示此推送以項目里面打包的sound.caf聲音來提醒,
                                // 如果系統(tǒng)沒有此音頻則以系統(tǒng)默認聲音提醒;此字段如果傳空字符串,iOS9及以上的系統(tǒng)是無聲音提醒,以下的系統(tǒng)是默認聲音
                                .setSound("default")
                                // 此字段為透傳字段,不會顯示在通知欄。用戶可以通過此字段來做一些定制需求,如特定的key傳要指定跳轉的頁面(value)
                                .addExtra("iosNotification extras key", extras)
                                // 此項說明此推送是一個background推送,想了解background看:http://docs.jpush.io/client/ios_tutorials/#ios-7-background-remote-notification
                                // 取消此注釋,消息推送時ios將無法在鎖屏情況接收
                                // .setContentAvailable(true)
                                .build())
                        .build())
                // Platform指定了哪些平臺就會像指定平臺中符合推送條件的設備進行推送。jpush的自定義消息,
                // sdk默認不做任何處理,不會有通知提示。建議看文檔http://docs.jpush.io/guideline/faq/的
                // [通知與自定義消息有什么區(qū)別?]了解通知和自定義消息的區(qū)別
                .setMessage(Message.newBuilder()
                        .setMsgContent(msgContent)
                        .setTitle(msgTitle)
                        .addExtra("message extras key", extras)
                        .build())
                .setOptions(Options.newBuilder()
                        // 此字段的值是用來指定本推送要推送的apns環(huán)境,false表示開發(fā),true表示生產;對android和自定義消息無意義
                        .setApnsProduction(apnsProduction)
                        // 此字段是給開發(fā)者自己給推送編號,方便推送者分辨推送記錄
                        .setSendno(1)
                        // 此字段的值是用來指定本推送的離線保存時長,如果不傳此字段則默認保存一天,最多指定保留十天;
                        .setTimeToLive(86400)
                        .build())
                .build();
    }
    /**
     * 向android平臺所有用戶推送消息
     *
     * @param notificationTitle
     * @param msgTitle
     * @param msgContent
     * @param extras
     * @return
     */
    private PushPayload buildPushObject_android_all_alertWithTitle(String notificationTitle, String msgTitle, String msgContent, String extras) {
        return PushPayload.newBuilder()
                // 指定要推送的平臺,all代表當前應用配置了的所有平臺,也可以傳android等具體平臺
                .setPlatform(Platform.android())
                // 指定推送的接收對象,all代表所有人,也可以指定已經設置成功的tag或alias或該應應用客戶端調用接口獲取到的registration id
                .setAudience(Audience.all())
                // jpush的通知,android的由jpush直接下發(fā),iOS的由apns服務器下發(fā),Winphone的由mpns下發(fā)
                .setNotification(Notification.newBuilder()
                        // 指定當前推送的android通知
                        .addPlatformNotification(AndroidNotification.newBuilder()
                                .setAlert(notificationTitle)
                                .setTitle(notificationTitle)
                                // 此字段為透傳字段,不會顯示在通知欄。用戶可以通過此字段來做一些定制需求,如特定的key傳要指定跳轉的頁面(value)
                                .addExtra("androidNotification extras key", extras)
                                .build())
                        .build()
                )
                // Platform指定了哪些平臺就會像指定平臺中符合推送條件的設備進行推送。jpush的自定義消息,
                // sdk默認不做任何處理,不會有通知提示。建議看文檔http://docs.jpush.io/guideline/faq/的
                // [通知與自定義消息有什么區(qū)別?]了解通知和自定義消息的區(qū)別
                .setMessage(Message.newBuilder()
                        .setMsgContent(msgContent)
                        .setTitle(msgTitle)
                        .addExtra("message extras key", extras)
                        .build())
                .setOptions(Options.newBuilder()
                        // 此字段的值是用來指定本推送要推送的apns環(huán)境,false表示開發(fā),true表示生產;對android和自定義消息無意義
                        .setApnsProduction(apnsProduction)
                        // 此字段是給開發(fā)者自己給推送編號,方便推送者分辨推送記錄
                        .setSendno(1)
                        // 此字段的值是用來指定本推送的離線保存時長,如果不傳此字段則默認保存一天,最多指定保留十天,單位為秒
                        .setTimeToLive(86400)
                        .build())
                .build();
    }
    /**
     * 向ios平臺所有用戶推送消息
     *
     * @param notificationTitle
     * @param msgTitle
     * @param msgContent
     * @param extras
     * @return
     */
    private PushPayload buildPushObject_ios_all_alertWithTitle(String notificationTitle, String msgTitle, String msgContent, String extras) {
        return PushPayload.newBuilder()
                // 指定要推送的平臺,all代表當前應用配置了的所有平臺,也可以傳android等具體平臺
                .setPlatform(Platform.ios())
                // 指定推送的接收對象,all代表所有人,也可以指定已經設置成功的tag或alias或該應應用客戶端調用接口獲取到的registration id
                .setAudience(Audience.all())
                // jpush的通知,android的由jpush直接下發(fā),iOS的由apns服務器下發(fā),Winphone的由mpns下發(fā)
                .setNotification(Notification.newBuilder()
                        // 指定當前推送的android通知
                        .addPlatformNotification(IosNotification.newBuilder()
                                // 傳一個IosAlert對象,指定apns title、title、subtitle等
                                .setAlert(notificationTitle)
                                // 直接傳alert
                                // 此項是指定此推送的badge自動加1
                                .incrBadge(1)
                                // 此字段的值default表示系統(tǒng)默認聲音;傳sound.caf表示此推送以項目里面打包的sound.caf聲音來提醒,
                                // 如果系統(tǒng)沒有此音頻則以系統(tǒng)默認聲音提醒;此字段如果傳空字符串,iOS9及以上的系統(tǒng)是無聲音提醒,以下的系統(tǒng)是默認聲音
                                .setSound("default")
                                // 此字段為透傳字段,不會顯示在通知欄。用戶可以通過此字段來做一些定制需求,如特定的key傳要指定跳轉的頁面(value)
                                .addExtra("iosNotification extras key", extras)
                                // 此項說明此推送是一個background推送,想了解background看:http://docs.jpush.io/client/ios_tutorials/#ios-7-background-remote-notification
                                // .setContentAvailable(true)
                                .build())
                        .build()
                )
                // Platform指定了哪些平臺就會像指定平臺中符合推送條件的設備進行推送。jpush的自定義消息,
                // sdk默認不做任何處理,不會有通知提示。建議看文檔http://docs.jpush.io/guideline/faq/的
                // [通知與自定義消息有什么區(qū)別?]了解通知和自定義消息的區(qū)別
                .setMessage(Message.newBuilder()
                        .setMsgContent(msgContent)
                        .setTitle(msgTitle)
                        .addExtra("message extras key", extras)
                        .build())
                .setOptions(Options.newBuilder()
                        // 此字段的值是用來指定本推送要推送的apns環(huán)境,false表示開發(fā),true表示生產;對android和自定義消息無意義
                        .setApnsProduction(apnsProduction)
                        // 此字段是給開發(fā)者自己給推送編號,方便推送者分辨推送記錄
                        .setSendno(1)
                        // 此字段的值是用來指定本推送的離線保存時長,如果不傳此字段則默認保存一天,最多指定保留十天,單位為秒
                        .setTimeToLive(86400)
                        .build())
                .build();
    }
    /**
     * 推送所有平臺的個人 registrationId指定用戶
     * @Date 10:48 2020/2/28
     * @Param paramMap id:指定的registrationId;title:消息頭;msg:消息體
     * @return PushResult
     */
    public static PushResult pushIndividual(Map<String, String> paramMap) {
        //創(chuàng)建JPushClient
        JPushClient jpushClient = new JPushClient(masterSecret, appKey);
        //創(chuàng)建option
        PushPayload payload = PushPayload.newBuilder()
                //所有平臺
                .setPlatform(Platform.all())
                //registrationId指定用戶
                .setAudience(Audience.registrationId(paramMap.get("id")))
                //.setAudience(Audience.all())
                .setNotification(Notification.newBuilder()
                        //發(fā)送ios
                        .addPlatformNotification(IosNotification.newBuilder()
                                //消息體
                                .setAlert(paramMap.get("msg"))
                                .setBadge(+1)
                                //ios提示音
                                .setSound("happy")
                                //附加參數
                                .addExtras(paramMap)
                                .build())
                        //發(fā)送android
                        .addPlatformNotification(AndroidNotification.newBuilder()
                                //消息頭
                                .setTitle(paramMap.get("title"))
                                //附加參數
                                .addExtras(paramMap)
                                //消息體
                                .setAlert(paramMap.get("msg"))
                                .build())
                        .build())
                //指定開發(fā)環(huán)境 true為生產模式 false 為測試模式 (android不區(qū)分模式,ios區(qū)分模式)
                .setOptions(Options.newBuilder().setApnsProduction(false).build())
                //自定義信息
                .setMessage(Message.newBuilder().setMsgContent(paramMap.get("msg")).addExtras(paramMap).build())
                .build();
        try {
            PushResult result= jpushClient.sendPush(payload);
            return result;
        } catch (APIConnectionException e) {
            System.out.println("pushIndividual{}"+e);
        } catch (APIRequestException e) {
            System.out.println("pushIndividual{}"+e);
        }
        return null;
    }
    public static void main(String[] args) {
        // registrationId推送
        /*Map<String, String> paramMap=new HashMap<String, String>();
        paramMap.put("id","100d85590845a22b981");
        paramMap.put("msg","Hello 1999");
        paramMap.put("title","通知消息199");
        MyJPushClient.pushIndividual(paramMap);*/
        // 別名推送
        MyJPushClient jPushUtil = new MyJPushClient();
        List<String> aliasList = Arrays.asList("116");
        String notificationTitle = "notificationTitle";
        String msgTitle = "msgTitle";
        String msgContent = "msgContent";
        jPushUtil.sendToAliasList(aliasList, notificationTitle, msgTitle, msgContent, "exts");
    }
}

4.test

@RunWith(SpringRunner.class)
@SpringBootTest
public class JPushApplicationTests {
    @Autowired
    private MyJPushClient jPushClient;
    @Test
    public void testJPush() {
        List<String> aliasList = Arrays.asList("239");
        String notificationTitle = "notification_title";
        String msgTitle = "msg_title";
        String msgContent = "msg_content";
        jPushClient.sendToAliasList(aliasList, notificationTitle, msgTitle, msgContent, "exts");
    }
}

到此這篇關于SpringBoot集成極光推送的實現代碼的文章就介紹到這了,更多相關SpringBoot集成極光推送 內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • Spring如何使用通知?Advice?管理事務

    Spring如何使用通知?Advice?管理事務

    Spring 默認采用聲明式事務管理(通過配置的方式) ,也可以實現編程式事務管理,這篇文章主要介紹了Spring使用通知Advice管理事務,需要的朋友可以參考下
    2023-06-06
  • Spring Boot使用FastJson解析JSON數據的方法

    Spring Boot使用FastJson解析JSON數據的方法

    本篇文章主要介紹了Spring Boot使用FastJson解析JSON數據的方法,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-02-02
  • JDK8?HashMap擴容算法demo

    JDK8?HashMap擴容算法demo

    這篇文章主要為大家介紹了JDK8?HashMap擴容算法demo,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-07-07
  • IDEA創(chuàng)建javaee項目依賴war exploded變紅失效的解決方案

    IDEA創(chuàng)建javaee項目依賴war exploded變紅失效的解決方案

    在使用IntelliJ IDEA創(chuàng)建JavaEE項目時,可能會遇到Tomcat部署的warexploded文件出現問題,解決方法是首先刪除有問題的warexploded依賴,然后根據圖示重新導入項目,此外,調整虛擬路徑有時也能有效解決問題
    2024-09-09
  • mybatis中orderBy(排序字段)和sort(排序方式)引起的bug及解決

    mybatis中orderBy(排序字段)和sort(排序方式)引起的bug及解決

    這篇文章主要介紹了mybatis中orderBy(排序字段)和sort(排序方式)引起的bug,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-01-01
  • Spring事務annotation原理詳解

    Spring事務annotation原理詳解

    這篇文章主要介紹了Spring事務annotation原理詳解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2020-02-02
  • SpringBoot項目Jar包使用systemctl運行過程

    SpringBoot項目Jar包使用systemctl運行過程

    這篇文章主要介紹了SpringBoot項目Jar包使用systemctl運行過程,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-03-03
  • Spring使用IOC與DI實現完全注解開發(fā)

    Spring使用IOC與DI實現完全注解開發(fā)

    IOC也是Spring的核心之一了,之前學的時候是采用xml配置文件的方式去實現的,后來其中也多少穿插了幾個注解,但是沒有說完全采用注解實現。那么這篇文章就和大家分享一下,全部采用注解來實現IOC + DI
    2022-09-09
  • Java的Volatile實例用法及講解

    Java的Volatile實例用法及講解

    在本篇文章里小編給大家整理了關于Java的Volatile知識點相關內容,有需要的朋友們可以跟著學習下。
    2019-09-09
  • Java之字節(jié)碼以及優(yōu)勢案例講解

    Java之字節(jié)碼以及優(yōu)勢案例講解

    這篇文章主要介紹了Java之字節(jié)碼以及優(yōu)勢案例講解,本篇文章通過簡要的案例,講解了該項技術的了解與使用,以下就是詳細內容,需要的朋友可以參考下
    2021-08-08

最新評論

习水县| 葫芦岛市| 玛沁县| 南江县| 文成县| 万全县| 咸宁市| 老河口市| 苏州市| 永嘉县| 农安县| 棋牌| 张北县| 依兰县| 潼关县| 靖宇县| 平山县| 元朗区| 枣强县| 双桥区| 辉南县| 余干县| 鞍山市| 武平县| 盈江县| 锡林浩特市| 日土县| 南平市| 潞城市| 锡林浩特市| 丰城市| 弥渡县| 元氏县| 西乡县| 娱乐| 屏东市| 汾阳市| 神池县| 临猗县| 临沧市| 湘潭县|