firebase.messaging().getInitialNotification() does not work on android(when app is killed)

Viewed 551

So, I have migrated Firebase on my project from v@5 to v@14 because push-notifications did not work on android API31+(v12) at all.

NOTE: we use react-native-splash-screen. Folk pointed out on some problems react-native-firebase/issues/4005 and react-native-firebase/issues/2768 and react-native-splash-screen/issues/289 and suggested to move from older splash approach to react-native-bootsplash as an alternatiove, which was not really the solution for us. PS. any comments inside links above did not help

firebase.messaging().onNotificationOpenedApp - Unlike initial pushes, in background mode push service was performing well as expected.

1 Answers

My problem was resolved by using API from 3d-party library such react-native-push-notification instead of firebase.messaging().getInitialNotification().

const getAndroidInitialNotification = (remoteMessage: ReceivedNotification | null): void => {
  const data = remoteMessage?.data;

  if (data) {
     // Your code such deep links implementation, dispatch to reducer etc...
  }
};

PushService.popInitialNotification(handleInitialNotifications);

Hope this will help for somebody like me, who do not understand what is the affection of splash approach on firebase service and all related confusing stuff.

Related