小编Jak*_* G.的帖子

react-native-firebase:onNotificationOpenedApp 和 getInitialNotification 不适用于 iOS

我正在使用 react-native-firebase 7.0.1 中的云消息传递。

我不想在 firebase 中存储 iOS 设备令牌,所以我使用getAPNSToken()方法然后将它存储在我的后端。

我可以在设备上发送通知,按下它后,应用程序就会打开。

但是当我尝试从getInitialNotification()or获取消息时,onNotificationOpenedApp()它总是返回null/ undefined

它每次都适用于Android。

推送处理程序

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
      } …
Run Code Online (Sandbox Code Playgroud)

push-notification ios firebase react-native react-native-firebase

2
推荐指数
1
解决办法
2297
查看次数