[expo-notifications] No notification data if app is killed or inactive

Please provide the following:

  1. SDK Version: 43.0
  2. Platforms(Android/iOS/web/all): Android

Some relevant info

  • EAS managed builds
  • expo-notifications: 0.13.3
  • useNextNotificationsApi: true

Tested on physical devices

  • Google Pixel 6XL
  • Samsung Galaxy S8

Hi, we have sending/receiving the notifications working in our standalone builds. However, we’re trying to detect when our app has been opened by a push notification and use the information from there for open tracking and navigation.

It seems to work fine for us on iOS, but we don’t get anything when the app is either inactive or has been killed on Android. This is only happening on the Android standalone build (with/without dev client doesn’t matter). If app was active when the notification comes in, if you later navigate out of the app and then click on the notification, the data is there. We CAN get it working when running Expo Go, seeing notification data.

export const App: React.FC<{}> = () => {
  // Also tried with this; always undefined/null.
  // const last = Notifications.useLastNotificationResponse();
  // console.log({ last });

  const notificationListener = useRef<any>();
  const responseListener = useRef<any>();

  useEffect(() => {
    notificationListener.current = Notifications.addNotificationReceivedListener((notification) => {
      console.log('notification received', { notification });
    });

    responseListener.current = Notifications.addNotificationResponseReceivedListener((response) => {
      console.log('response received', { response });
    });

    return () => {
      Notifications.removeNotificationSubscription(notificationListener.current);
      Notifications.removeNotificationSubscription(responseListener.current);
    };
  }, []);

  return (
    <View>
      <Text>Hello World</Text>
    </View>
  );
};

We’ve already tried using this patch to no avail (able to add it getting applied/added console logging to see it running with patch): NotificationResponseReceivedListener not called when app is killed · Issue #14078 · expo/expo · GitHub

Is there something we’re missing?

So, figured out a way to make it run on the standalone; use the expo token and the push notification tool. We use a third party to handle sending notifications though, and the integrate only with APN/FCM directly.

Figured it out. Forgot to include experienceId/scopeKey as described here: Sending Notifications with APNs & FCM - Expo Documentation

1 Like

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