用于ios的Cordova Push Notifications插件Node-gcm

时间:2015-09-15 10:51:09

标签: cordova push-notification cordova-plugins

我正在尝试通过phonegap推送通知插件获取推送通知,到目前为止我已经能够使其适用于Android手机但我不知道如何处理notify.js文件以使其工作IOS。我已经完成了包含临时配置文件的所有步骤,并且应用程序注册了ID,但没有发送通知。

以下是我的notify.js for android的代码

var gcm = require('node-gcm');
var message = new gcm.Message();

//API Server Key
var sender = new gcm.Sender('ID');
var registrationIds = [];

// Value the payload data to send...
message.addData('message',"\u270C Peace, Love \u2764");
message.addData('title','Welcome!' );
message.addData('msgcnt','3'); // Shows up in the notification in the          status bar
message.addData('soundname','beep.wav'); //Sound to play upon notification receipt - put in the www folder in app
//message.collapseKey = 'demo';
//message.delayWhileIdle = true; //Default is false
message.timeToLive = 3000;// Duration in seconds to hold in GCM and retry before timing out. Default 4 weeks (2,419,200 seconds) if not  specified.

// At least one reg id required
registrationIds.push('ID');

/**
 * Parameters: message-literal, registrationIds-array, No. of retries, callback-function
 */
sender.send(message, registrationIds, 4, function (result) {
console.log(result);
});

干杯

0 个答案:

没有答案