在接收 Firebase 通知时打开应用程序(React Native - Android)

时间:2021-07-08 17:23:11

标签: android firebase react-native notifications firebase-cloud-messaging

我一直在尝试在 React Native Android 中接收来自 Firebase 的通知时打开该应用。

我尝试了以下代码,它只能在 Android 10 以下运行。 任何猜测如何使其在 Android 10 上运行。

我正在通知中发送一个名为 Super 的自定义密钥来实现这一点。

if (remoteMessage.getData().containsKey("Super")) {
    Intent launchIntentt = context.getPackageManager().getLaunchIntentForPackage("com.notifier");
      launchIntentt.putExtra("String_I_need", "strName");
      if (launchIntentt != null) {
        Log.d("Testing ", "Inside");
        context.startActivity(launchIntentt);
    }
}

我在位于 ReactNativeFirebaseMessagingReceiver.java 的 @react-native-firebase/messaging 文件中的 Firebase Messaging 库代码中添加了这段代码

我也尝试过放置前台服务,但没有帮助。

任何帮助将不胜感激。

0 个答案:

没有答案
相关问题