プッシュ通知は正常に機能するようになりましたが、プッシュ通知でカスタム データを送信する方法がわかりません。
プッシュ通知用のノード 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: 'titech!@#', /* 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」変数を送信したいと思います。
解決策を見つけるのを手伝ってください...
前もって感謝します。