wix / react-native-notifications

React Native Notifications
MIT License
3.23k stars 761 forks source link

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

Open Etaliya opened 1 year ago

silviaskura commented 1 year ago

same here

kristofb commented 1 year ago

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

Etaliya commented 1 year ago

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

Android 13

kristofb commented 1 year ago

Same for me in fact...

stale[bot] commented 1 year ago

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

kristofb commented 1 year ago

This issue is still valid.

kristofb commented 1 year ago

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

greenimpala commented 1 year ago

Still valid

skinsapp commented 1 year ago

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

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

oristian commented 1 year ago

thanks @kristofb - works. would appreciate a merge!

volle241 commented 1 year ago

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

greenimpala commented 1 year ago

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

diegoplatap commented 1 year ago

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, ); } })

stale[bot] commented 1 year ago

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

TwistedMinda commented 12 months ago

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

but none of these helped

Recap of the bug:

Tapping a notification:

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?

stale[bot] commented 11 months ago

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

zabojad commented 7 months ago

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

TwistedMinda commented 7 months ago

@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)  
  }
})