Springboot集成uniPush,包含华为荣耀厂商推送(完整版)

本代码适用于unipush1.0版本的个推使用

先在项目pom中导入个推依赖

<!-- APP个推 -->
        <dependency>
            <groupId>com.getui.push</groupId>
            <artifactId>restful-sdk</artifactId>
            <version>1.0.0.4</version>
        </dependency>

推送配置类:推送配置从配置文件中读取

import com.getui.push.v2.sdk.ApiHelper;
import com.getui.push.v2.sdk.GtApiConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 个推推送类
 */
@Configuration
public class GTPushConfig {

    @Value("${push.app_id}")
    private String appId;

    @Value("${push.app_key}")
    private String appKey;

    @Value("${push.master_secret}")
    private String masterSecret;

    @Bean(name = "myApiHelper")
    public ApiHelper apiHelper() {
        // 设置httpClient最大连接数,当并发较大时建议调大此参数。或者启动参数加上 -Dhttp.maxConnections=200
        System.setProperty("http.maxConnections", "200");

        GtApiConfiguration apiConfiguration = new GtApiConfiguration();
        // 填写应用配置
        apiConfiguration.setAppId(appId);
        apiConfiguration.setAppKey(appKey);
        apiConfiguration.setMasterSecret(masterSecret);
        // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
        // 默认为https://restapi.getui.com/v2
        apiConfiguration.setDomain("https://restapi.getui.com/v2/");
        // 实例化ApiHelper对象,用于创建接口对象
        ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
        return apiHelper;
    }
}

推送集成工具类:注意厂商推送的Intent配置里的component=com.xx.xx改成自己的安卓打包包名,

该推送包含了华为、荣耀厂商推送角标,已经测试过正常显示角标

import com.getui.push.v2.sdk.ApiHelper;
import com.getui.push.v2.sdk.api.PushApi;
import com.getui.push.v2.sdk.common.ApiResult;
import com.getui.push.v2.sdk.dto.CommonEnum;
import com.getui.push.v2.sdk.dto.req.Audience;
import com.getui.push.v2.sdk.dto.req.AudienceDTO;
import com.getui.push.v2.sdk.dto.req.Settings;
import com.getui.push.v2.sdk.dto.req.Strategy;
import com.getui.push.v2.sdk.dto.req.message.PushChannel;
import com.getui.push.v2.sdk.dto.req.message.PushDTO;
import com.getui.push.v2.sdk.dto.req.message.PushMessage;
import com.getui.push.v2.sdk.dto.req.message.android.AndroidDTO;
import com.getui.push.v2.sdk.dto.req.message.android.ThirdNotification;
import com.getui.push.v2.sdk.dto.req.message.android.Ups;
import com.getui.push.v2.sdk.dto.req.message.ios.Alert;
import com.getui.push.v2.sdk.dto.req.message.ios.Aps;
import com.getui.push.v2.sdk.dto.req.message.ios.IosDTO;
import com.getui.push.v2.sdk.dto.res.TaskIdDTO;
import com.opencloud.common.utils.JSONUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Component
public class UniPushUtils {

    // 消息推送
    public static final String MESSAGE_PUSH = "1";
    // 离线推送
    public static final String OFFLINE_PUSH = "2";

    @Resource(name = "myApiHelper")
    private ApiHelper myApiHelper;

    /**
     * 消息推送(离线推送)单cid推送
     */
    public ApiResult<Map<String, Map<String, String>>> pushToSingleByCid(String cid, String title, String content, String linkUrl, String type) {
        PushDTO<Audience> pushDTO = this.buildPushDTO(title, content, linkUrl, type);
        // 设置接收人信息
        Audience audience = new Audience();
        pushDTO.setAudience(audience);
        audience.addCid(cid); // cid
        // 进行cid单推
        PushApi pushApi = myApiHelper.creatApi(PushApi.class);
        ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO);
        if (apiResult.isSuccess()) {
            // success
            log.info("推送成功");
            System.out.println(apiResult.getData());
        } else {
            // failed
            log.error("推送失败");
            System.out.println("code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
        }
        return apiResult;
    }

    /**
     * 消息推送(离线推送)别名推送
     */
    public ApiResult<Map<String, Map<String, String>>> pushToSingleByAlias(String alias, String title, String content, String linkUrl, String type) {
        PushDTO<Audience> pushDTO = this.buildPushDTO(title, content, linkUrl, type);
        // 设置接收人信息
        Audience audience = new Audience();
        pushDTO.setAudience(audience);
        audience.addAlias(alias); // cid
        // 进行cid单推
        PushApi pushApi = myApiHelper.creatApi(PushApi.class);
        ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByAlias(pushDTO);
        if (apiResult.isSuccess()) {
            // success
            log.info("推送成功");
            System.out.println(apiResult.getData());
        } else {
            // failed
            log.error("推送失败");
            System.out.println("code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
        }
        return apiResult;
    }

    /**
     * cid批量推
     * @param cidList
     * @param title
     * @param content
     */
    public ApiResult<Map<String, Map<String, String>>> pushListByCid(List<String> cidList, String title, String content, String linkUrl, String type) {
        //批量发送
        AudienceDTO audienceDTO = new AudienceDTO();

        PushDTO<Audience> pushDTO = this.buildPushDTO(title, content, linkUrl, type);

        PushApi pushApi = myApiHelper.creatApi(PushApi.class);
        ApiResult<TaskIdDTO> createApiResult = pushApi.createMsg(pushDTO);
        if (! createApiResult.isSuccess()) {
            log.error("推送:创建消息失败"+createApiResult.getMsg());
        }
        // 设置接收人信息
        Audience audience = new Audience();
        pushDTO.setAudience(audience);
        audience.setCid(cidList);

        audienceDTO.setAudience(audience);
        audienceDTO.setTaskid(createApiResult.getData().getTaskId());
        audienceDTO.setAsync(true);

        ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushListByCid(audienceDTO);
        if (apiResult.isSuccess()) {
            // success
            log.info("推送成功");
        } else {
            // failed
            log.error("推送失败");
            System.out.println("code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
        }
        return apiResult;
    }

    /**
     * 推送所有用户
     *
     * @param title
     * @param content
     * @param linkUrl
     * @return
     */
    public ApiResult<TaskIdDTO> pushAll(String title, String content, String linkUrl, String type) {
        PushDTO<String> pushDTO = this.pushDTOAll(title, content, linkUrl, type);
        // 进行cid单推
        PushApi pushApi = myApiHelper.creatApi(PushApi.class);
        ApiResult<TaskIdDTO> apiResult = pushApi.pushAll(pushDTO);
        if (apiResult.isSuccess()) {
            // success
            log.info("推送成功");
            System.out.println(apiResult.getData());
        } else {
            // failed
            log.error("推送失败");
            System.out.println("code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
        }
        return apiResult;
    }

    /**
     * 推送全部组装消息实体
     *
     * @param title
     * @param content
     * @param linkUrl
     * @return
     */
    private PushDTO<String> pushDTOAll(String title, String content, String linkUrl, String type) {
        Map<String, String> map = new HashMap<>();
        map.put("title", title);
        map.put("content", content);
        map.put("linkUrl", linkUrl);
        map.put("type", type);
        // 转json对象
        String payload = JSONUtils.toJSONString(map);

        PushDTO<String> pushDTO = new PushDTO<String>();
        pushDTO.setRequestId(System.currentTimeMillis() + "");
        pushDTO.setGroupName("g-name1");

        Settings settings = new Settings();
        settings.setTtl(3600000);
        Strategy strategy = new Strategy();
        strategy.setSt(1);
        settings.setStrategy(strategy);

        pushDTO.setSettings(settings);

        //TODO 安卓IOS应用在线走个推通道
        PushMessage pushMessage = new PushMessage();
        Map<String, Object> mapTC = new HashMap<>();
        mapTC.put("title", title);
        mapTC.put("content", content);
        mapTC.put("linkUrl", linkUrl);
        mapTC.put("type", type);
        mapTC.put("payload", payload);
        String jsonTC = JSONUtils.toJSONString(mapTC);
        pushMessage.setTransmission(jsonTC);
        pushDTO.setPushMessage(pushMessage);

        //安卓应用离线走厂商
        PushChannel pushChannel = new PushChannel();
        AndroidDTO androidDTO = new AndroidDTO();
        Ups ups = new Ups();
        ThirdNotification thirdNotification = new ThirdNotification();
        thirdNotification.setClickType(CommonEnum.ClickTypeEnum.TYPE_INTENT.type);
        thirdNotification.setTitle(title);
        thirdNotification.setBody(content);
        thirdNotification.setIntent("intent://io.dcloud.unipush/?#Intent;scheme=unipush;launchFlags=0x4000000;" +
                "component=com.xx.xx/io.dcloud.PandoraEntry;S.UP-OL-SU=true;" +
                "S.title="+title+";" +
                "S.content="+content+";" +
                "S.payload="+payload+";end");
        ups.setNotification(thirdNotification);

        //设置options 方式二
        Map<String, Map<String, Object>> options = new HashMap<String, Map<String, Object>>();
        Map<String, Object> all = new HashMap<String, Object>();
        all.put("channel", "default");
        all.put("badgeAddNum", 1);
        all.put("badgeClass", "com.getui.demo.GetuiSdkDemoActivity");
        options.put("ALL", all);
        Map<String, Object> hw = new HashMap<String, Object>();
        options.put("HW", hw);
        hw.put("/message/android/notification/badge/class", "io.dcloud.PandoraEntry");
        hw.put("/message/android/notification/badge/add_num",1);
        Map<String, Object> ho = new HashMap<String, Object>();
        options.put("HO", ho);
        ho.put("/message/android/notification/badge/badgeClass", "io.dcloud.PandoraEntry");
        ho.put("/message/android/notification/badge/addNum",1);
        ups.setOptions(options);


        androidDTO.setUps(ups);
        pushChannel.setAndroid(androidDTO);

        IosDTO iosDTO = new IosDTO();
        Aps aps = new Aps();
        Alert alert = new Alert();
        alert.setTitle(title);
        alert.setBody(content);
        aps.setContentAvailable(0);
        aps.setSound("default");
        aps.setAlert(alert);
        iosDTO.setPayload(payload);
        iosDTO.setAps(aps);
        iosDTO.setType("notify");
        iosDTO.setAutoBadge("+1");//苹果角标
        pushChannel.setIos(iosDTO);
        pushDTO.setPushChannel(pushChannel);

        return pushDTO;
    }

    /**
     * 消息参数模板
     */
    private PushDTO<Audience> buildPushDTO(String title, String content, String linkUrl, String type) {
        Map<String, String> map = new HashMap<>();
        map.put("title", title);
        map.put("content", content);
        map.put("linkUrl", linkUrl);
        map.put("type", type);
        // 转json对象
        String payload = JSONUtils.toJSONString(map);

        PushDTO<Audience> pushDTO = new PushDTO<Audience>();
        pushDTO.setRequestId(System.currentTimeMillis() + "");
        pushDTO.setGroupName("g-name1");

        Settings settings = new Settings();
        settings.setTtl(3600000);
        Strategy strategy = new Strategy();
        strategy.setSt(1);
        settings.setStrategy(strategy);

        pushDTO.setSettings(settings);

        //TODO 安卓IOS应用在线走个推通道
        PushMessage pushMessage = new PushMessage();
        Map<String, Object> mapTC = new HashMap<>();
        mapTC.put("title", title);
        mapTC.put("content", content);
        mapTC.put("linkUrl", linkUrl);
        mapTC.put("type", type);
        mapTC.put("payload", payload);
        String jsonTC = JSONUtils.toJSONString(mapTC);
        pushMessage.setTransmission(jsonTC);
        pushDTO.setPushMessage(pushMessage);

        //TODO 安卓应用离线走厂商
        PushChannel pushChannel = new PushChannel();
        AndroidDTO androidDTO = new AndroidDTO();
        Ups ups = new Ups();
        ThirdNotification thirdNotification = new ThirdNotification();
        thirdNotification.setClickType(CommonEnum.ClickTypeEnum.TYPE_INTENT.type);
        thirdNotification.setTitle(title);
        thirdNotification.setBody(content);
        thirdNotification.setIntent("intent://io.dcloud.unipush/?#Intent;scheme=unipush;launchFlags=0x4000000;" +
                "component=com.xx.xx/io.dcloud.PandoraEntry;S.UP-OL-SU=true;" +
                "S.title="+title+";" +
                "S.content="+content+";" +
                "S.payload="+payload+";end");
        ups.setNotification(thirdNotification);

        //设置options 方式二
        Map<String, Map<String, Object>> options = new HashMap<String, Map<String, Object>>();
        Map<String, Object> all = new HashMap<String, Object>();
        all.put("channel", "default");
        all.put("badgeAddNum", 1);
        all.put("badgeClass", "com.getui.demo.GetuiSdkDemoActivity");
        options.put("ALL", all);
        Map<String, Object> hw = new HashMap<String, Object>();
        options.put("HW", hw);
        hw.put("/message/android/notification/badge/class", "io.dcloud.PandoraEntry");
        hw.put("/message/android/notification/badge/add_num",1);
        Map<String, Object> ho = new HashMap<String, Object>();
        options.put("HO", ho);
        ho.put("/message/android/notification/badge/badgeClass", "io.dcloud.PandoraEntry");
        ho.put("/message/android/notification/badge/addNum",1);
        ups.setOptions(options);


        androidDTO.setUps(ups);
        pushChannel.setAndroid(androidDTO);

        //TODO ios离线推送
        IosDTO iosDTO = new IosDTO();
        Aps aps = new Aps();
        Alert alert = new Alert();
        alert.setTitle(title);
        alert.setBody(content);
        aps.setContentAvailable(0);
        aps.setSound("default");
        aps.setAlert(alert);
        iosDTO.setPayload(payload);
        iosDTO.setAps(aps);
        iosDTO.setType("notify");
        iosDTO.setAutoBadge("+1");
        pushChannel.setIos(iosDTO);
        pushDTO.setPushChannel(pushChannel);
        return pushDTO;
    }

    /**
     * 离线通知消息参数模板
     */
    private PushDTO<Audience> offlinePushDTO(String title, String content, String linkUrl, String type) {
        PushDTO<Audience> pushDTO = new PushDTO<>();
        // 设置推送参数
        //requestid需要每次变化唯一
        pushDTO.setRequestId(System.currentTimeMillis() + "");
        pushDTO.setGroupName("wxb-group");
        // PushMessage在线走个推通道才会起作用的消息体

        Map<String, String> map = new HashMap<>();
        map.put("title", title);
        map.put("content", content);
        map.put("linkUrl", linkUrl);
        map.put("type", type);

        PushMessage pushMessage = new PushMessage();
        pushDTO.setPushMessage(pushMessage);
        Map<String, Object> mapTC = new HashMap<>();
        mapTC.put("title", title);
        mapTC.put("content", content);
        mapTC.put("payload", map);
        String jsonTC = JSONUtils.toJSONString(mapTC);
        System.err.println(jsonTC);
        pushMessage.setTransmission(jsonTC);
        log.info("pushDTO:{}", pushDTO);
        return pushDTO;
    }
}

单元测试参考:

//String alias = "29f27029ec9245a49335c02bff224952";//ios
        String cid = "ba0c214fdf43f434gfg44545dghg4ttt";//iosk
        String title = "“金点子”征集活动上线啦!";
        String content = "2023年公司工作会暨职工代表大会金点子征集活动上线!点击参与“金点子”征集活动,赢精美礼品!";
        String linkUrl = "/pages/viewactivityweb/viewactivityweb?";
        String type = "click";
        //ApiResult<Map<String, Map<String, String>>> map = uniPushUtils.pushToSingleByAlias(cid,title,content,linkUrl,type);
        ApiResult<TaskIdDTO> map = uniPushUtils.pushAll(title,content,linkUrl,type);

 

APP端代码仅供参考:

App.vue中处理消息监听:

//消息推送监听处理
//#ifdef APP-PLUS
			plus.push.addEventListener("click", function(msg) {
				var payload = {};
				var platform = uni.getSystemInfoSync().platform;
				if (platform == "ios") {
					if (msg['type'] == "click") {
						//通过苹果服务器通知过来的消息
						payload = msg['payload'];
					} else {
						//通过个推透传,创建本地通知的消息
						payload = JSON.parse(JSON.parse(msg.payload));
					}
				} else if (platform == 'android') {
					payload = msg.payload;
				}
				//跳转对应页面
				setTimeout(function() {
					if (payload.linkUrl) {
						uni.navigateTo({
							url: payload.linkUrl,
						})
					}
				}, 1000)
			}, false);

			//在线消息推送监听处理
			plus.push.addEventListener("receive", function(msg) {
				console.log("receive:" + msg)
				var platform = uni.getSystemInfoSync().platform;
				let payload = msg.payload
				if (platform == "ios") {
					if (msg.type == "receive") // 这里判断触发的来源,否则一直推送。  
						{
							//ios平台应用在前台时,不能收到通知消息,只能走透传,在创建一条本地消息 plus.push.createMessage(msg.content, JSON.stringify(msg.payload), { title: msg.title });
							var options = {
								cover: false,
								title: msg.title
							};
							//创建一条推送消息
							plus.push.createMessage(msg.content, JSON.stringify(msg.payload), options); 
							//添加在线消息提示点
							getApp().globalData.badgeNumber = getApp().globalData.badgeNumber+1;
							plus.runtime.setBadgeNumber(getApp().globalData.badgeNumber);
						}
				} else if (platform == 'android') {
					var options = {
						cover: false,
						title: msg.title
					};
					//创建一条推送消息
					plus.push.createMessage(msg.content, JSON.stringify(msg.payload), options); 
					//添加在线消息提示点
					getApp().globalData.badgeNumber = getApp().globalData.badgeNumber+1;
					plus.runtime.setBadgeNumber(getApp().globalData.badgeNumber);
				}

			}, false);
			// #endif

App端绑定别名以及处理清除消息提示点:

新建getui.js

function igexinTool() {
    var isAndorid, PushManager, context, Instance, GeTuiSdk, UIApplication, oldNum;
	//#ifdef APP-PLUS
		if (plus.os.name == 'Android') {
		    isAndorid = true;
		} else {
		    isAndorid = false;
		}
		
		if (isAndorid) {
		    PushManager = plus.android.importClass("com.igexin.sdk.PushManager");
		    context = plus.android.runtimeMainActivity().getContext();
		    Instance = PushManager.getInstance();
		} else {
		    GeTuiSdk = plus.ios.importClass("GeTuiSdk");
		}
	// #endif
    this.bindAlias = function(alias) {
        if (isAndorid) {
            Instance.bindAlias(context, alias);
        } else {
            GeTuiSdk.bindAliasandSequenceNum(alias, alias);
        }
    }

    this.unbindAlias = function(alias) {
        if (isAndorid) {
            Instance.unBindAlias(context, alias, true);
        } else {
            GeTuiSdk.unbindAliasandSequenceNumandIsSelf(alias, alias, true);
        }
    }

    this.getVersion = function() {
        if (isAndorid) {
            return Instance.getVersion(context);
        } else {
            return GeTuiSdk.version;
        }
    }

    //开启推送  
    this.turnOnPush = function() {
        if (isAndorid) {
            Instance.turnOnPush(context);
        } else {
            GeTuiSdk.setPushModeForOff(false);
        }
    }

    //关闭推送  
    this.turnOffPush = function() {
        if (isAndorid) {
            Instance.turnOffPush(context);
        } else {
            GeTuiSdk.setPushModeForOff(true);
        }
    }
	
	//清除消息角标
	this.clearnBadge = function() {
	    getApp().globalData.badgeNumber = 0;
	    //清除角标
	    if (isAndorid) {
	    	//设置应用图标的数量
	    	plus.runtime.setBadgeNumber(0);
	    	plus.runtime.setBadgeNumber(-1);
	    } else {
	    	//设置应用图标的数量
	    	plus.runtime.setBadgeNumber(0);
	    	GeTuiSdk.setBadge(0);
	    }
	}

}
export default igexinTool 

清除消息角标:

App.vue引入js

import igexinTool from '@/config/getui.js'
onShow: function() {
			//清除消息角标
			var tool = new igexinTool();
			tool.clearnBadge();	
		},

绑定推送别名:

在需要绑定别名的业务逻辑页面引入js

import igexinTool from '@/config/getui.js'
var tool = new igexinTool();
tool.bindAlias('需要绑定的别名 如:用户ID');

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一些主流厂商推送通道的参数配置示例: ### 小米推送 ```json { "provider": "xiaomi", "payload": { "registration_id": "yourDeviceRegId", "restricted_package_name": "yourPackageName", "pass_through": 0, // 穿透消息:0-通知栏消息,1-透传消息 "notify_type": -1, // 通知类型:-1-默认通知,1-静默通知,2-默认声音,3-自定义声音,4-振动,5-呼吸灯 "title": "Push Title", // 通知栏消息标题 "description": "Push Content", // 通知栏消息正文 "payload": "yourPayload", // 透传消息内容 "extra": { "key1": "value1", // 自定义参数 "key2": "value2" }, "notify_id": 0, // 通知ID "time_to_live": 86400, // 离线消息保留时长(秒) "timeToSend": 0, // 定时推送时间(秒),0表示立即推送 "notify_foreground": 1 // 是否在前台展示通知:0-不展示,1-展示 }, "config": { "appSecret": "yourAppSecret" // 应用秘钥 } } ``` 需要注意的是,小米推送需要在官网上注册并创建应用,获取到应用秘钥和设备注册ID。 ### 华为推送 ```json { "provider": "huawei", "payload": { "hps": { "msg": { "type": 3, // 消息类型:1-透传异步消息,3-通知栏消息 "body": { "title": "Push Title", // 通知栏消息标题 "content": "Push Content", // 通知栏消息正文 "badge": 1, // 角标 "sound": "default", // 声音 "click_action": { "type": 1, // 点击通知后的行为:1-打开APP首页,2-打开自定义页面,3-打开URL "intent": "#Intent;compo=com.rvr/.Activity;S.W=U;end" }, "extras": { "key1": "value1", // 自定义参数 "key2": "value2" } } } }, "token_list": [ "yourDeviceToken" ] }, "config": { "appId": "yourAppId", // 应用ID "appSecret": "yourAppSecret" // 应用秘钥 } } ``` 需要注意的是,华为推送需要在官网上注册并创建应用,获取到应用ID和应用秘钥。 ### 魅族推送 ```json { "provider": "meizu", "payload": { "registration_ids": [ "yourDeviceRegId" ], "title": "Push Title", // 通知栏消息标题 "content": "Push Content", // 通知栏消息正文 "ticker": "Push Ticker", // 通知栏消息滚动文字 "is_multiple": 0, // 是否多包名推送:0-否,1-是 "click_type": 0, // 点击通知栏后的行为:0-打开应用,1-打开URL,2-自定义行为 "click_activity": "yourActivity", // 点击通知栏后打开的Activity "click_url": "yourUrl", // 点击通知栏后打开的URL "custom_content": { "key1": "value1", // 自定义参数 "key2": "value2" }, "off_line": true, // 是否离线推送 "valid_time": 432000, // 离线消息保留时长(秒) "push_time": "2022-01-01 00:00:00" // 定时推送时间 }, "config": { "appId": "yourAppId", // 应用ID "appSecret": "yourAppSecret" // 应用秘钥 } } ``` 需要注意的是,魅族推送需要在官网上注册并创建应用,获取到应用ID和应用秘钥。 ### vivo推送 ```json { "provider": "vivo", "payload": { "reg_id": "yourDeviceRegId", "notify_type": 4, // 通知类型:1-默认,2-静音,3-振动,4-声音,5-呼吸灯 "title": "Push Title", // 通知栏消息标题 "content": "Push Content", // 通知栏消息正文 "skip_type": 2, // 点击通知栏后的行为:1-打开应用,2-打开URL,3-自定义行为 "skip_content": "yourUrl", // 点击通知栏后打开的URL "network_type": -1, // 网络类型:-1-任意网络,1-仅WIFI "client_custom_map": { "key1": "value1", // 自定义参数 "key2": "value2" }, "request_id": "yourReqId", // 请求ID,必须唯一 "time_to_live": 86400, // 离线消息保留时长(秒) "time_for_off_line": 86400, // 离线消息转为在线消息的时长(秒) "target_type": 1, // 推送范围:1-指定RegId,2-所有设备 "push_mode": 0 // 推送模式:0-正式,1-测试(仅发送给测试设备) }, "config": { "appId": "yourAppId", // 应用ID "appKey": "yourAppKey", // 应用秘钥 "appSecret": "yourAppSecret" // 应用秘钥 } } ``` 需要注意的是,vivo推送需要在官网上注册并创建应用,获取到应用ID、应用秘钥和应用秘钥。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值