我正在开发我的第一个 PhoneGap/Cordova 应用程序,但在使 iOS 推送通知正常工作时遇到了问题。
我的环境如下:
- Cordova 版本:3.5.0-0.2.7
- 推送插件版本:2.4.0
- XCode 版本:6.1.1
这是代码
var pushNotification = window.plugins.pushNotification;
pushNotification.register(mag.notifications.tokenHandler, mag.notifications.errorHandler, { "badge": "true", "sound": "true", "alert": "true", "ecb": "mag.notifications.onNotificationAPN" });
tokenHandler: function (result) {
mag.environment.alert("iOS registration successful.");
mag.notifications.registerId(result);
},
errorHandler: function (error) {
mag.environment.alert(error);
console.log(error);
},
onNotificationAPN: function (e) {
debugger;
mag.environment.alert("iOS notification received");
},
但是,无论我如何尝试测试或部署(iOS 模拟器,通过 xCode 在设备上,通过测试飞行在设备上),都不会触发任何回调,也不会出现任何错误。
在苹果开发中心,我设置了我的应用程序 ID,并为开发和分发启用了推送通知。
如有任何帮助,我们将不胜感激。
最佳答案
对我来说,我在 iOS 通知设置中关闭了我的应用程序的“角标(Badge)应用程序图标”。打开它解决了问题。
更新:
现在我什至可以关闭“角标(Badge)应用程序图标”,并且回调仍然可以正确触发。即使重新安装应用程序后也是如此。
关于ios - PhoneGap/Cordova pushplugin iOs 注册回调未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27807414/