0

I am using expo push notifications while testing I found that when the app is open(foreground) and receives a notification, then if we tap on the notification no event is called. I tried addNotificationResponseReceivedListener but not working.

I attached the code below:

useEffect(()=>{
  const subscription = Notifications.addNotificationResponseReceivedListener((response) => {
    console.log(response
  });

  return () => {
    // Clean up the event listeners
    subscription.remove();
  };
},[])

When the app is in the killed state I get a response using useLastNotificationResponse when the user taps on the notification.

const lastNotificationResponse =
    Notifications.useLastNotificationResponse();

useEffect(() => {
    if (lastNotificationResponse) {
     console.log('lastNotificationResponse',JSON.stringify(lastNotificationResponse));

    }
}, [lastNotificationResponse]);

So I want notification details when the user taps on the notification and the app is in a foreground/background state.

"expo-notifications": "~0.27.6",
"expo": "~50.0.5",

0