SDK 45
Development build (no Expo Go)
Hi! On iOS, when receiving a notification in the foreground I can’t get the notification object in NotificationReceived nor NotificationResponseReceived.
I have setup addNotificationReceivedListener and addNotificationResponseReceivedListener and no mater what, if I receive a notification in the foreground, I can’t get the notification console logged, and if I tap a notification nothing gets logged either!
This is my partial setupNotifications.js file:
...
...
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: false,
}),
});
export default function setupNotifications() {
const notificationListener = useRef();
const responseListener = useRef();
useEffect(() => {
...
...
// This listener is fired whenever a notification is received while the app is foregrounded
notificationListener.current = Notifications.addNotificationReceivedListener((notification) => {
console.log('Received a notification in the foreground!', Platform.OS, notification); // No logs at all!
});
// This listener is fired whenever a user taps on or interacts with a notification (works when app is foregrounded, backgrounded, or killed)
responseListener.current = Notifications.addNotificationResponseReceivedListener((response) => {
console.log('Received a notification response!', Platform.OS, response); // No logs at all!
});
return () => {
Notifications.removeNotificationSubscription(notificationListener.current);
Notifications.removeNotificationSubscription(responseListener.current);
};
}, []);
...
...
...
}