baumstumpf
baumstumpf

Reputation: 202

getInitialNotification of React Native Firebase returns notification object only for first push notification

I have a weird problem with @react-native-firebase/messaging. I recently updated to v6 and everything works well on iOS and on Android everything works well except for one thing.

When getting multiple push notifications the following is the case:

  1. Clicking on one notification opens the app and getInitialNotification() gives me the clicked notification, so I can handle it
  2. When closing the app completely and then clicking on one of the other notifications the app opens again, but getInitialNotification() returns null

It seems like opening the app with one notification eats the data of all the other notifications as well. I guess I'm doing something wrong, but I have no clue where I can search for the issue.

Some information about the setup

Upvotes: 2

Views: 3279

Answers (1)

Vinit Bhavsar
Vinit Bhavsar

Reputation: 252

messaging().onNotificationOpenedApp(remoteMessage => {
      console.log(
        'Notification caused app to open from background state:',
        remoteMessage.notification,
      );
      navigation.navigate(remoteMessage.data.type);
    });

Add this listner

https://rnfirebase.io/messaging/notifications

Upvotes: -1

Related Questions