Node+Dcloud integrates a push push platform

Don't say anything about registration, just say single push and all push.

For a single push, you need to get the clientid of the mobile application

Get clientid code

var cid = plus.push.getClientInfo().clientid;

background call code

var template = new NotificationTemplate({
	appId: APPID,
	appKey: APPKEY,
	title: obj.title,
	text: obj.text,
	logoUrl: 'http://wwww.igetui.com/logo.png',
        isRing: true,
	isVibrate: true,
	isClearable: false,
	transmissionType: obj.num,
	transmissionContent: obj.content
});
var message = new SingleMessage({//Specify cid push
	isOffline: true, //Whether offline
	offlineExpireTime: 3600 * 12 * 1000, //offline time
	data: template, //Set the push message type
	pushNetWorkType:0 //whether wifi, 0 unlimited, 1wifi
});
var target = new Target({
	appId: APPID,
	clientId: CID
});
 gt.pushMessageToSingle(message, target, function(err, res){
       console.log(res);
        if(err != null && err.exception != null && err.exception instanceof  RequestError){
             var requestId = err.exception.requestId;
             console.log(err.exception.requestId);
             gt.pushMessageToSingle(message,target,requestId,function(err, res){
                 console.log(err);
                 console.log(res);
           });
     }
 });

All push

var template = new NotificationTemplate({
	    	appId: APPID,
	        appKey: APPKEY,
	        title: obj.title,
	        text: obj.text,
	        logoUrl: 'http://wwww.igetui.com/logo.png',
	        isRing: true,
	        isVibrate: true,
	        isClearable: false,
	        transmissionType: obj.num,
	        transmissionContent: obj.content
	    });
	    var taskGroupName = null;
	    var message = new AppMessage({
	        isOffline: false,
	        offlineExpireTime: 3600 * 12 * 1000,
	        data: template,
	        appIdList: [APPID],
	        speed: 10000
	    });
	
	    gt.pushMessageToApp(message, taskGroupName, function (err, res) {
	        console.log(res);
	    });

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324778215&siteId=291194637