【发布时间】:2019-03-12 13:03:06
【问题描述】:
我有一个有趣的问题,我正在尝试使用插件 cordova-plugin-firebase (https://github.com/arnesson/cordova-plugin-firebase) 在 iOS 上解决。通过 Firebase 控制台或 cURL 代码发送通知可以正常工作,但通知始终会同时发送到设备通知中心并显示在应用程序中,即使它是前台也是如此。根据文档,通知流程应该是当应用程序在前台时通知不会传递到设备。我没有对应用程序委托或插件代码等进行任何修改。所以我不确定从哪里开始调试。
这是我的代码中的 onNotificationOpen 回调,只要应用程序处于前台或打开通知时,它就会被调用
window.FirebasePlugin.onNotificationOpen(function(notification) {
console.log(notification);
alert(notification);
}, function(error) {
console.error(error);
});
Cordova iOS 平台是 4.5.5。 cordova-plugin-firebase 是 2.0.3,设备 iOS 是 12.0
【问题讨论】:
-
糟糕,我发了这个帖子,原来是插件github.com/arnesson/cordova-plugin-firebase/issues/817中的一个错误
-
对我来说,简单的解决方案是在 AppDelegate+FirebasePlugin.m 的完整处理程序中添加 UNNotificationPresentationOptionNone 而不是 UNNotificationPresentationOptionAlert,如下所述:github.com/arnesson/cordova-plugin-firebase/pull/835
标签: ios xcode firebase cordova firebase-cloud-messaging