I've been using react-native-push-notification library for quite some time for local notifications. Now I need remote silent notifications. Basically I send a notification that gets delivered to onNotification callback and I send local notification to the notification center.
I expect onNotification callback to trigger every time I receive notification and I open an app by clicking on notification. The problem is, depending on where I call PushNotification.configure({...})
, on Android it triggers onNotification when notification gets delivered OR when I click on it, but never both! My code:
// if here: calls onNotification when it's received
PushNotifications.configureNotifications();
export default class App extends React.Component {
constructor(props) {
// if here: calls onNotification when I click on it to open an app
PushNotifications.configureNotifications();
super(props);
}
render() { ... }
}
PushNotifications.configureNotifications()
- it's just a simple wrapper over the library configure call. Yes, tried to keep it in both places - doesn't work. What am I doing wrong?
I always send data payload in push notification.