react-native-push-notification icon indicating copy to clipboard operation
react-native-push-notification copied to clipboard

Handle navigation

Open juntiapps opened this issue 3 years ago • 3 comments

hi guys. I want to handle navigation to another screen when I tap on the notification with condition the app is closed (not running). is there any way? I can handle navigation for foreground and background condition by calling NotificationServices.js in my home screen.
But when I tap on the notification when app is closed, the app is opened, but does not navigate to another screen.

My current flow for background condition is notification clicked, go to home, forwarded to designed screen. My current flow for foreground condition is notification clicked, forwarded to designed screen.

I use remote notification by FCM

Thanks.

juntiapps avatar Apr 21 '22 03:04 juntiapps

you can delay with setTimeout

irsyaadbp avatar Apr 25 '22 22:04 irsyaadbp

See react-navigation doc (if you use this lib): https://reactnavigation.org/docs/navigating-without-navigation-prop/#handling-initialization Then check "else" condition. You have to handle an "queue" until navigation ref is ready.

You can also check deep-linking doc to handle deep-link payload in your notification: https://reactnavigation.org/docs/deep-linking/#third-party-integrations

But it is not an issue about react-native-push-notification, it's more related to your navigation library.

Aure77 avatar Apr 29 '22 13:04 Aure77

what if i want to dispatch an action inside onNotification? That must be an issue about React- Redux. Right?

mohity777 avatar May 09 '22 20:05 mohity777

How can i get 'navigation' object in index.js ? because my push notification received in index.js so i want redirect on specific screen on click on.

ox-vishal avatar Jan 09 '23 05:01 ox-vishal

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jan 11 '24 00:01 github-actions[bot]