I'm using react-navigation and react-native-push-notification. How can I open a certain StackNavigator's screen in onNotification callback? Should work when:
- app is closed
- app is in the foreground
- app is in the background
I only need it working in Android for now.
I've tried to pass a callback function to notification in my component:
_handleClick() {
PushNotification.localNotification({
foreground: false
userInteraction: false
message: 'My Notification Message'
onOpen: () => { this.props.navigation.navigate("OtherScreen") },
})
}
And to fire onOpen in PushNotification config:
onNotification: function(notification) {
notification.onOpen()
}
But it seems that functions can't be passed to notification, unless a value is a string it's ignored, causing onOpen to be undefined.