Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Etaliya opened this issue Mar 22, 2023 · 18 comments

Comments

@Etaliya
Copy link

Etaliya commented Mar 22, 2023

No description provided.

@Etaliya Etaliya changed the title Notifications.getInitialNotification() is undefined when click on notification in quite state Notifications.getInitialNotification() is undefined when click on notification in quite state [ANDROID] Mar 22, 2023
@silviaskura
Copy link

same here

@kristofb
Copy link

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

@Etaliya
Copy link
Author

Etaliya commented Apr 27, 2023

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

Android 13

@kristofb
Copy link

Same for me in fact...

@stale
Copy link

stale bot commented Jun 9, 2023

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 stale bot added the 🏚 stale label Jun 9, 2023
@kristofb
Copy link

This issue is still valid.

@stale stale bot removed the 🏚 stale label Jun 11, 2023
@kristofb
Copy link

May be solved by #966

@greenimpala
Copy link

Still valid

@skinsapp
Copy link

skinsapp commented Jun 14, 2023

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

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

@oristian
Copy link

thanks @kristofb - works. would appreciate a merge!

@volle241
Copy link

volle241 commented Jun 27, 2023

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

@greenimpala
Copy link

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
Copy link

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
Copy link

stale bot commented Aug 10, 2023

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 stale bot added the 🏚 stale label Aug 10, 2023
@TwistedMinda
Copy link

TwistedMinda commented Sep 14, 2023

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?

@stale
Copy link

stale bot commented Oct 15, 2023

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 stale bot added the 🏚 stale label Oct 15, 2023
@zabojad
Copy link

zabojad commented Feb 5, 2024

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

@stale stale bot removed the 🏚 stale label Feb 5, 2024
@TwistedMinda
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants