【发布时间】:2020-09-20 17:28:00
【问题描述】:
我正在使用 react-native-firebase 7.0.1 中的云消息传递。
我不想将 iOS 设备令牌存储在 Firebase 中,所以我使用 getAPNSToken() 方法,然后将其存储在我的后端。
我可以在设备上发送通知,按下它后,应用程序就会打开。
但是当我尝试从getInitialNotification() 或onNotificationOpenedApp() 获取消息时,它总是返回null/undefined。
它每次都可以在 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;
}
}
【问题讨论】:
-
我遇到了同样的问题,现在正在解决它。如果我弄清楚了,会告诉你的。您在这方面取得了进展吗?
-
我也面临同样的问题。 @LouieAnderson-你能分享一下你是如何解决这个问题的吗?
标签: ios firebase react-native push-notification react-native-firebase