【发布时间】:2017-09-06 22:28:18
【问题描述】:
我正在使用cordova插件添加phonegap-plugin-push --variable 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'”。
【问题讨论】:
-
我的回答对您的问题有帮助吗?
标签: android cordova push-notification phonegap-plugins