b8ne / react-native-pusher-push-notifications

Manage pusher interest subscriptions and notification events in Javascript.
MIT License
96 stars 85 forks source link

navigate to specific screen after tap on notification #119

Open iamhaaamed opened 1 year ago

iamhaaamed commented 1 year ago

How can we navigate the user to a specific screen when the user tap on notifications?

Sulaiman122 commented 9 months ago

You need to send a body on the notification from the backend or pusher "debug console" and then handle the notification on "handleNotification" function as it will show you the body of the alert

anniewey commented 2 months ago

I'm having similar problem navigating due to the limitation discussed in https://github.com/b8ne/react-native-pusher-push-notifications/issues/97.

Since the instance and event listener has to be called at index.js, I have no access to navigation props to navigate user to certain screen. Have to follow this docs to implement the navigation

RNPusherPushNotifications.on('notification', (payload: any) => {
      console.log('PAYLOAD received', payload);
      if (payload.data.key === 'profile') {
        RootNavigation.navigate('Profile');
      }
    });