React Native push notification working in foreground not working in background and killed mode

245 views Asked by At

I am developing a React Native application I have a push notification scenario where if I send notification through firebase FCM tester I was able to open the application both in foreground and background mode. While receiving a real time notification I was not able to navigate to the application from the background mode, it works fine with foreground mode. In both the scenarios killed mode is not working.

Below message is the FCM tester notification console in the application

Message handled in the background {"collapseKey": "com.appname", "data": {}, "from": "senderId", "messageId": "someId", "notification": {"android": {}, "body": "Test notif", "title": "Notif"}, "sentTime": 1697699932985, "ttl": 2419200}

Below message is the realtime notification console in the application

Message handled in the background {"collapseKey": "com.appname", "data": {}, "from": "senderId", "messageId": "someId", "notification": {"android": {"clickAction": "https://dev.google.com"}, "body": "Some message", "title": "Some title"}, "sentTime": 1697700076410, "ttl": 2419200}

These are my project dependencies and versions. I have been using react-native-push-notification package for android and react-native-notifications for iOS.
I need to know how to implement three modes of notification (forground , background , killed mode) using these packages.

"dependencies": {
    ***
    "@react-native-firebase/app": "^18.5.0",
    "@react-native-firebase/messaging": "^18.5.0",
    "react": "18.2.0",
    "react-native": "0.72.5",
    "react-native-gesture-handler": "^2.13.1",
    "react-native-notifications": "^5.1.0",
    "react-native-push-notification": "^8.1.1",
    ***
  },

In the apps entry point I have configured like this

import { AppRegistry, Platform } from "react-native";
import App from "./App";
import { name as appName } from "./app.json";
import { Notifications } from "react-native-notifications";
import messaging from "@react-native-firebase/messaging";

Notifications.registerRemoteNotifications();

if (Platform.OS === "ios") {
  Notifications.ios.checkPermissions().then(currentPermissions => {
    console.log("Ios permissions", currentPermissions);
  });
}

AppRegistry.registerComponent(appName, () => App);
0

There are 0 answers