0
現在推送通知正常工作,但我不知道如何通過推送通知發送自定義數據。節點js蘋果推送通知與發送自定義數據
我的推送通知節點js庫是'apn'。
代碼推送通知:
var apns = require('apn');
/* Data to be send with push notification */
var ntfnDetails = {};
ntfnDetails = data.ntfnDetails;
var options = {
cert: 'FitCert.pem', /* Certificate file path */
certData: null, /* String or Buffer containing certificate data, if supplied uses this instead of cert file path */
key: 'FITHUDLEKEY.pem', /* Key file path */
keyData: null, /* String or Buffer containing key data, as certData */
passphrase: '[email protected]#', /* A passphrase for the Key file */
ca: null, /* String or Buffer of CA data to use for the TLS connection */
gateway: 'gateway.push.apple.com',/* gateway address */
port: 2195, /* gateway port */
enhanced: true, /* enable enhanced format */
errorCallback: undefined, /* Callback when error occurs function(err,notification) */
cacheLength: 100 /* Number of notifications to cache for error purposes */
};
var apnsConnection = new apns.Connection(options);
var myDevice = data.device_id;
var note = new apns.Notification();
note.expiry = Math.floor(Date.now()/1000) + 3600; // Expires 1 hour from now.
note.badge = 3;
note.alert = 'Hellooo';
note.payload = {'messageFrom': 'Caroline'};
apnsConnection.pushNotification(note, myDevice);
在此我想給「ntfnDetails」變量,這個推送通知。
請幫我找到一個解決辦法...
在此先感謝。
謝謝你的回覆,它的工作。 –