1
我正在使用科爾多瓦插件添加phonegap-plugin-push - 變量SENDER_ID = XXXXXXXX 這個插件。並將以下代碼添加到JavaScript文件中。在科爾多瓦的推送通知
function setupPush() {
var push = PushNotification.init({
"android": {
"senderID": "XXXXXXXX"
},
"ios": {
"sound": true,
"alert": true,
"badge": true
},
"windows": {}
});
push.on('registration', function(data) {
console.log("registration event: " + data.registrationId);
var oldRegId = localStorage.getItem('registrationId');
if (oldRegId !== data.registrationId) {
// Save new registration ID
localStorage.setItem('registrationId', data.registrationId);
// Post registrationId to your app server as the value has changed
}
});
push.on('error', function(e) {
console.log("push error = " + e.message);
});
}
它給出的錯誤爲「TypeError:無法調用未定義的方法init」。
我的回答對你的問題有幫助嗎? –