首页 > 解决方案 > onNotificationOpened 适用于 Android 模拟器,但不适用于实际设备

问题描述

我在我的 react-native 应用程序中使用 firebase 通知模块。它在模拟器中完美运行,但是当我在移动设备中安装应用程序时,打开通知时永远不会调用 onNotificationOpened 事件侦听器。我错过了什么?

环境

构建工具:

代码片段:

  this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
      Linking.openURL('https://www.google.com/');
  });

  /*
  * If your app is closed, you can check if it was opened by a notification being clicked / tapped / opened as follows:
  * */
  const notificationOpen = await firebase.notifications().getInitialNotification();
  if (notificationOpen) {
      Linking.openURL('https://www.google.com/');
  }

标签: androidfirebasereact-nativefirebase-cloud-messagingreact-native-android

解决方案


推荐阅读