zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.73k stars 2.05k forks source link

Can't Add navigation in configure in Index.js #2327

Closed Zein0 closed 4 months ago

Zein0 commented 1 year ago

I'm implementing the configuration as the documentation suggested in the index.js file Note I'm using local Notification only for foreground notifications ( else it's triggered from firebase ) so if it's not necessary to put my configure in index.js please tell me Now in my index.js I can't use navigation or a hook that calls a navigate in my onNotification: function (notification){ if(notification.foreground&&notification.userInteraction){ navigation.navigate(notification.data.url) } }, What could I'm doing wrong

tdammy92 commented 1 year ago

@Zein0 Have you been able to resolve this ? am also having similar issues.

ox-vishal commented 1 year ago

Any one got solution of this question ?

rdick commented 1 year ago

@ox-vishal @tdammy92 @Zein0 were you able to figure this out?

It is only happening for me when you boot the app from a notification

tdammy92 commented 1 year ago

@ox-vishal @rdick Am not using this package anymore, Using only firebase since i could call my message().OnNotification from where i have access to navigation, so am good to go.

github-actions[bot] commented 5 months ago

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.

Zein0 commented 4 months ago

A bit late I've managed to solve it by using a custom Navigation RootNavigation.navigate(notification.data.url, props); My RootNavigation file you use an isReadyRef that will updated in the onReady props function in your NavigationContainer and you check if ur app is ready you navigate using navigationRef which ref the same NavigationContainer else you don't do anything so far in production I didn't face any issue since Im using it for foreground notifications only so my app is always ready @rdick @ox-vishal