我用react-navigation
和react-native-push-notification
.如何在onNotification
回调中打开某个StackNavigator's
屏幕?应在以下情况下工作:
- 应用程序已关闭
- 应用程序在前台
- 应用程序在后台
我现在只需要它在安卓系统中工作.
我试图在我的组件中将回调函数传递给通知:
_handleClick() {
PushNotification.localNotification({
foreground: false
userInteraction: false
message: 'My Notification Message'
onOpen: () => { this.props.navigation.navigate("OtherScreen") },
})
}
要在PushNotification
配置中触发onOpen
:
onNotification: function(notification) {
notification.onOpen()
}
但函数似乎不能传递给通知,除非一个值是一个字符串,它被忽略,导致onOpen
未定义.