ios - 使用 RNFirebase 从 iOS 通知中心获取所有通知
问题描述
我正在使用 RNFirebase 5.20.1 构建一个 React Native 应用程序,并寻找一种在通知中心(适用于 iOS)中获取所有通知的方法,类似于getDeliveredNotifications
(https://facebook.github.io/react-native/docs/ 0.55/pushnotificationios#getdeliverednotifications)。
我在 RNFirebase 的源代码或文档中没有找到类似这种方法的东西(https://github.com/invertase/react-native-firebase/blob/v5.xx/ios/RNFirebase/notifications/RNFirebaseNotifications.m)。
RNFirebase 确实提供了一种方法removeAllDeliveredNotifications
来清除通知中心的所有通知,但返回一个包含 void 的承诺,所以我也无法从中获取任何数据。
我也考虑过实现 RN PushNotificationIOS 库,但有点担心它会与 RNFirebase 冲突(与 RNFirebase 集成方法有重叠,而且我对本机代码的理解非常初级)。
有任何想法吗?也许我根本没有看到 RNFirebase 方法来做到这一点......
更新
所以我已经集成了 PushNotificationIOS 库,只是在 AppDelegate.m 文件中更改了一件事,它似乎已经奏效了——我能够从通知中心访问通知。
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
[[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
[RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
}
解决方案
推荐阅读
- c# - 如何使用 C# 将变量设置为至少是最小值
- openedge - msgOpen:无法打开消息文件:PROMSGS
- ruby - 在没有 webhook 的情况下自动接受 Google 日历上的“新时间建议”?
- python - 线程与多处理器 Python
- vue.js - 表引导 vue
- java - WSO2 Identity Server 5.10.0 with Samples 4.2.0 继续有 java.lang.ClassCastException: class org.opensaml.saml1.core.impl.ActionBuilder
- azure - AKS:--api-server-authorized-ip-ranges 过滤器
- terraform - 如何在数据源中使用常规 for 循环?
- google-app-engine - 在 Google App Engine 上托管网站 | 502 错误网关 | Worker 无法启动(记录器)
- javascript - 如何使用 webRTC 将静态视频文件从一个浏览器发送到另一个浏览器?