How to redirect push notifications using listener in Expo

My goal is to submit some custom data together with the push notification itself and then, once it goes on the device and I open the notification to navigate/route/redirect the app to a specific screen that I have defined. I have configured the notifications, I get expo tokens, I receive the notification, it goes in the [handler] but when I try to apply the navigation that I use throughout my whole app: Error is : [Unhandled promise rejection: TypeError: undefined is not an object (evaluating ‘_this.props.navigation.push’)]

_handleNotifications= async (notification) => {

const {origin} = notification;

console.log("_handleNotification", notification)

alert(‘entered into _handleNotification’)

if (origin === ‘selected’) {

this.props.navigation.push('AcceptTermsconditions')

alert('entered into AcceptTermsconditions')

console.log("origin is AcceptTermsconditions")

} else {
// origin is ‘received’

// show notification at the top of my app instead of navigate to other screen

console.log("origin is received")

}
}

Problem is solved. Place the above code at initialRoute.
Thank you

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.