fellow React Native developers! I’m encountering an issue with local notifications in my React Native app. Specifically, the onNotification function isn’t being triggered when a notification is received/clicked. I need to handle navigation based on the notification click, but since the function isn’t firing, I’m unable to capture the event. Here’s a brief overview of my setup: React Native version: “0.72.4”, Device/Emulator: iPhone X (real device) and emulators I’ve configured my PushNotification in the following way:
PushNotification.configure({
// ... other configurations ...
onNotification: function(notification) {
console.log('Notification Received', notification);
// Navigation logic here
},
});
The notifications are being received correctly, and everything else seems to be working fine. However, when I click on a notification, nothing happens — no console log, no navigation, nothing. Here’s what I’ve checked so far: Verified that other console logs work properly, and notifications are received. Checked the library versions for compatibility. Made sure the app requests and receives the correct permissions. I’m at a bit of a loss here and would greatly appreciate any insights or suggestions you might have. Has anyone faced a similar issue, or does anyone know what might be going wrong? Thank you in advance for your help!
In my React Native app, I attempted to configure local notifications using the react-native-push-notification library. I expected the onNotification function to be triggered when a notification is clicked, allowing me to handle navigation to specific screens based on the notification data.
What I tried:
Configuring the onNotification function within PushNotification.configure. Ensuring that the app has the correct permissions to receive notifications. Testing on both real device and emulators to check for consistent behavior. What I expected:
The onNotification function to log the notification details in the console. Navigation to occur based on the interaction with the notification. What actually happened:
The notifications were received correctly but clicking them did not trigger the onNotification function. There was no console log output or navigation action upon notification click.