所以,我上的PhoneGap,我使用:Phonegap PushNotification,如何使用具有phonegap的節點推送服務器?
所以,我安裝了第一個插件,我可以得到我的手機令牌。在那之後,我創建了一個節點server.js
文件在我的根目錄有:
var apn = require('apn');
var token = "MY TOKEN";
var device = new apn.Device(token);
var notification = new apn.Notification();
notification.expiry = Math.floor(Date.now()/1000) + 3600;
notification.badge = 1;
notification.alert = "This is a Push Notification=)";
notification.payload = {'prop': 'special value'};
notification.device = device;
var options = {
gateway: 'gateway.sandbox.push.apple.com',
cert: 'CER.pem',
key: 'KEY.pem',
passphrase: 'password'
}
var apnsConnection = new apn.Connection(options);
apnsConnection.pushNotification(notification, device);
當我開始我的服務器node server.js
在命令行中,我可以看到我的手機在我的推送通知,因此,所有它的確定。
但我的問題,我需要在我的代碼(phonegap)不同的地方發送推送通知。我怎樣才能做到這一點 ?
當我的server.js
正在運行時,如何從我的phonegap應用程序發送其他推送通知?