react native firebase:onNotificationOpenedApp和getInitialNotification在iOS上不工作
我使用的是来自react native firebase 7.0.1的云消息 我不想在firebase中存储iOS设备令牌,所以我使用react native firebase:onNotificationOpenedApp和getInitialNotification在iOS上不工作,ios,firebase,react-native,push-notification,react-native-firebase,Ios,Firebase,React Native,Push Notification,React Native Firebase,我使用的是来自react native firebase 7.0.1的云消息 我不想在firebase中存储iOS设备令牌,所以我使用getAPNSToken()方法,然后将其存储在后端 我能够在设备上发送通知,按下后,应用程序打开 但当我试图从getInitialNotification()或onNotificationOpenedApp()获取消息时,它总是返回null/未定义的 它每次在Android上都能工作 PushHandler.js import React from 'react
getAPNSToken()
方法,然后将其存储在后端
我能够在设备上发送通知,按下后,应用程序打开
但当我试图从getInitialNotification()
或onNotificationOpenedApp()
获取消息时,它总是返回null
/未定义的
它每次在Android上都能工作
PushHandler.js
import React from 'react';
import messaging from '@react-native-firebase/messaging';
export default class PushHandler extends React.Component {
constructor(props) {
super(props);
this.messageApp = messaging();
}
componentDidMount() {
this.messageApp.onNotificationOpenedApp(remoteMessage => {
if (remoteMessage) { // <- always null on iOS
// handle notification
}
});
this.messageApp.getInitialNotification().then(initialMessage => {
if (initialMessage) { // <- always undefined on iOS
// handle notification
}
});
}
render() {
return null;
}
}
从“React”导入React;
从“@react native firebase/messaging”导入消息;
导出默认类PushHandler扩展React.Component{
建造师(道具){
超级(道具);
this.messageApp=messaging();
}
componentDidMount(){
this.messageApp.onNotificationOpenedApp(remoteMessage=>{
if(remoteMessage){//{
如果(initialMessage){/刚刚意识到,根据文档,这些功能仅在通过FCM发送和接收通知时起作用,这就是为什么在通过APN手动发送通知时,您看不到这些功能起作用的原因
此软件包将允许利用getInitialNotification和其他功能:刚刚意识到,根据文档,这些功能仅在通过FCM发送和接收通知时有效,这就是为什么在通过APN手动发送通知时无法看到这些功能
此软件包将允许利用getInitialNotification和其他功能:它以前曾经工作过。我的意思是,对于RNFirebase 5.x.x版本。
出于某种原因,库的维护人员决定只在Firebase云消息通过时将这些事件发送到JS层
下面是IF语句:
我删除了IF语句,它似乎像以前一样工作。
但是,是的,这是RN Firebase库的新特性。它以前是工作的。我的意思是,对于RNFirebase 5.x.x版本。
出于某种原因,库的维护人员决定只在Firebase云消息通过时将这些事件发送到JS层
下面是IF语句:
我删除了IF语句,它似乎像以前一样工作。
但是,是的,这是RN Firebase库的新行为。我现在遇到了同样的问题并正在解决它。如果我能解决它,我会告诉你。你在这里取得了进展吗?我也面临着同样的问题。@LouieAnderson-你能分享你如何解决这个问题的详细信息吗?我现在遇到同样的问题并正在解决它。Will如果我发现了,请告诉你。你在这方面取得了进展吗?我也面临着同样的问题。@LouieAnderson-你能分享你如何解决这个问题的细节吗?