Notification Listener is never called if app is in background.

SDK Version: 38.0.0
Platforms: Android

Notifications.addNotificationReceivedListener callback is never called if the app is running in background.

The example from your docs:

import React from 'react';
import * as Notifications from 'expo-notifications';

export default function App() {
  React.useEffect(() => {
    const subscription = Notifications.addNotificationReceivedListener(notification => {
      // This is never called if the app is in background
      console.log(notification);
    });
    return () => subscription.remove();
  }, []);

  return (
    // Your app content
  );
}

Reproducable in Expo and in standalone mode.

UPDATE:
It appears that in the Notifications Overview docs it’s stated that this works only on foreground:
(Push Notifications Overview - Expo Documentation)

...
// This listener is fired whenever a notification is received while the app is foregrounded
    Notifications.addNotificationReceivedListener(notification => {
      setNotification(notification);
    });
...

Well, does anyone know how to handle notifications while the app is in background?
As for addNotificationResponseReceivedListener is when the user interacts with the Noti. It’s different thing.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.