iOSプッシュ通知を実装しようとしています。私のPHPのバージョンは動作を停止し、私は再び動作させることができませんでした。しかし、Appleの新しい認証キーを使用して完全に動作するnode.jsスクリプトがあります。私が使用してPHPからそれを呼び出すことができる午前:PHP exec()からNode.jsスクリプトを呼び出すときに、どのようにパラメータを渡すことができますか?
chdir("../apns");
exec("node app.js &", $output);
しかし、私はそれにdeviceTokenとメッセージを渡すことができるようにしたいと思います。スクリプトにパラメータを渡す方法はありますか?あなたが他のスクリプトにそれを渡すよう
var apn = require('apn');
var apnProvider = new apn.Provider({
token: {
key: 'apns.p8', // Path to the key p8 file
keyId: '<my key id>', // The Key ID of the p8 file (available at https://developer.apple.com/account/ios/certificate/key)
teamId: '<my team id>', // The Team ID of your Apple Developer Account (available at https://developer.apple.com/account/#/membership/)
},
production: false // Set to true if sending a notification to a production iOS app
});
var deviceToken = '<my device token>';
var notification = new apn.Notification();
notification.topic = '<my app>';
notification.expiry = Math.floor(Date.now()/1000) + 3600;
notification.badge = 3;
notification.sound = 'ping.aiff';
notification.alert = 'This is a test notification \u270C';
notification.payload = {id: 123};
apnProvider.send(notification, deviceToken).then(function(result) {
console.log(result);
process.exit(0)
});
それは素晴らしい作品!ありがとう! – Lastmboy
@Lastmboyようこそ –