因此,我已将项目中的 Firebase 从 v@5 迁移到 v@14,因为推送通知在 android API31+(v12) 上根本不起作用。
注意:我们使用 react-native-splash-screen
。民间指出一些问题react-native-firebase/issues/4005和 react-native-firebase/issues/2768和 react-native-splash-screen/issues/289并建议从旧的 splash 方法转移到 react-native-bootsplash
作为替代方案,这对我们来说并不是真正的解决方案。
附言。上面链接内的任何评论都没有帮助
firebase.messaging().onNotificationOpenedApp
- 与初始推送不同,在后台模式下,推送服务按预期表现良好。
最佳答案
我的问题已通过使用来自 3d 方库的 API 解决,例如 react-native-push-notification
而不是 firebase.messaging().getInitialNotification()
.
const getAndroidInitialNotification = (remoteMessage: ReceivedNotification | null): void => {
const data = remoteMessage?.data;
if (data) {
// Your code such deep links implementation, dispatch to reducer etc...
}
};
PushService.popInitialNotification(handleInitialNotifications);
希望这对像我这样的人有所帮助,他们不了解splash approach 对 firebase 服务的影响以及所有相关的令人困惑的东西。
关于android - firebase.messaging().getInitialNotification() 在 android 上不起作用(当应用程序被杀死时),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70893858/