onPress don´t work with react-navigation
davidcort opened this issue · comments
I am using this plugin with react-navigation and the push notification from OneSignal, all is fine but the function onPress not works.
`
import NotificationPopup from 'react-native-push-notification-popup';
//**Execute when a notification is received
onReceived = notification => {
console.log("Notification received: ", notification)
//Show Push Notification Popup
const pushMessage = notification.payload.title
const link = notification.payload.additionalData.noticia
notification.isAppInFocus == true
&& this.popup.show({
onPress: () => NavigationService.navigate('NoteContainer', { link }), //With function() the same, not works
appIconSource: require('./assets/icon.png'),
appTitle: 'UNOTV',
timeText: 'Ahora',
title: pushMessage
})
}
render() {
return (
<MainContainer>
<StatusBar backgroundColor="#FAFAFA" barStyle="dark-content" />
/** The pop-pup display very well but the onPress function and Pan gestures not works
<NotificationPopup ref={ref => this.popup = ref} />
//App container with use of react native Context
<NotificationsContext.Provider value={this.state}>
<AppContainer
ref={navigatorRef => {
NavigationService.setTopLevelNavigator(navigatorRef)
}}
/>
</NotificationsContext.Provider>
</MainContainer>
)
}
`
Can you try onPress: function() {console.log('Pressed')}
see if it works?
I am guessing your NavigationService.navigate doesn't work because it is outside your <AppContainer>
, which is the top level navigator. Maybe try put the popup component inside.
It is weird that the pan gesture doesn't work. It should have nothing to do with this. Any log or screen capture will be helpful.
Well, is works if the NotificationPopup change to bottom. I dont know why.
return (
/** The pop-pup display very well but the onPress function and Pan gestures not works
//App container with use of react native Context
<NotificationsContext.Provider value={this.state}>
<AppContainer
ref={navigatorRef => {
NavigationService.setTopLevelNavigator(navigatorRef)
}}
/>
</NotificationsContext.Provider>
<NotificationPopup ref={ref => this.popup = ref} />
)That's weird. I am not sure about the reason. But glad that you fixed it.