ios - PhoneGap/Cordova pushplugin iOs 注册回调未触发

标签 ios cordova push-notification phonegap-pushplugin

我正在开发我的第一个 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/

相关文章:

iphone - UIView 上的圆角不精确

jquery - cakephp中如何接收并处理json对象?

android - navigator.geolocation.getCurrentPosition 总是在 Android 中超时,直到 GPS/位置关闭

ios - 我可以在 iOS 中自定义推送通知的外观吗?

ios - iOS NSDateFormatter无法正确解析小时

iOS Swift Parse 此查询具有出色的网络连接。你必须等到它完成

visual-studio - Cordova:使用 VS 2017 中的 --allow-file-access-from-files 启动 chrome

ios - 使用推送通知提供商有什么好处吗?

java - GCM 推送通知实现

ios - 如何以编程方式调整 UIImage 的大小,就像设置scaleAspectFill 内容模式一样?