react-native-notifications icon indicating copy to clipboard operation
react-native-notifications copied to clipboard

Notifications.getInitialNotification() is undefined when click on notification in quite state [ANDROID]

Open Etaliya opened this issue 2 years ago • 18 comments

Etaliya avatar Mar 22 '23 06:03 Etaliya

same here

silviaskura avatar Apr 14 '23 14:04 silviaskura

In which version of Android are you experiencing this problem? It may be related to https://github.com/wix/react-native-notifications/pull/920

kristofb avatar Apr 26 '23 16:04 kristofb

In which version of Android are you experiencing this problem? It may be related to #920

Android 13

Etaliya avatar Apr 27 '23 04:04 Etaliya

Same for me in fact...

kristofb avatar Apr 27 '23 07:04 kristofb

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Jun 09 '23 23:06 stale[bot]

This issue is still valid.

kristofb avatar Jun 11 '23 19:06 kristofb

May be solved by https://github.com/wix/react-native-notifications/pull/966

kristofb avatar Jun 11 '23 19:06 kristofb

Still valid

greenimpala avatar Jun 14 '23 10:06 greenimpala

Indeed it is solved by #966 , well done @kristofb !!

(verified on Android 13, on a Pixel 6 pro)

skinsapp avatar Jun 14 '23 15:06 skinsapp

thanks @kristofb - works. would appreciate a merge!

oristian avatar Jun 15 '23 05:06 oristian

The problem still valid without @kristofb's PR. How can we speed up merge process?

volle241 avatar Jun 27 '23 06:06 volle241

You can apply a patch for now @volle241. Although we still see the issue on some devices so I'm not 100% convinced this solves it.

react-native-notifications+4.3.5.patch

greenimpala avatar Jun 27 '23 11:06 greenimpala

If your provider is FCM, what works for me consistenly was to add yarn add @react-native-firebase/messaging and use:

messaging() .getInitialNotification() .then(remoteMessage => { if (remoteMessage) { console.log( 'Notification caused app to open from quit state:', remoteMessage.notification, ); } })

diegoplatap avatar Jul 04 '23 21:07 diegoplatap

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Aug 10 '23 02:08 stale[bot]

Hi, is anyone still stuck on this issue? Because I am. Tried all the options provided here and there:

  • applying the patch
  • testing the recent react-native-notifications 5.0.0
  • use firebase's getInitialNotification instead
  • replace react-native-splash-screen by react-native-bootsplash
  • testing different launchMode (singleTask, singleTop, singleInstance, standard & even singleInstancePerTask)

but none of these helped

Recap of the bug:

Tapping a notification:

  • opens correctly when app is on background
  • opens correctly when app is quitted
  • opens by restarting the activity when app is on foreground

The activity doesn't seem to really restart entirely: SplashScreen appears but the navigation state is preserved. It would still be okay if getInitialNotification() would return the notification tapped, but it's not.

Am I the only one?

TwistedMinda avatar Sep 14 '23 12:09 TwistedMinda

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Oct 15 '23 08:10 stale[bot]

@TwistedMinda in my case, it works. Can you share the code where you call Notifications.getInitialNotification() ?

zabojad avatar Feb 05 '24 17:02 zabojad

@zabojad Hey, good to know it can work!

Well I don't really do anything fancy, just calling it:

Notifications.getInitialNotification().then((notification) => {
  if (notification) {
    handleNotification(notification)  
  }
})

TwistedMinda avatar Feb 13 '24 19:02 TwistedMinda

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Jan 31 '25 22:01 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Feb 24 '25 23:02 stale[bot]