Notification does not appear in foreground only on iOS

Background information:

  1. SDK Version: 42.0.1
  2. Platforms(Android/iOS/web/all): Android & iOS
  3. expo-notifications version: 0.13.3

I want to have my notification displayed in the foreground when the app is running. I follow every bit of the code in the document: Notifications - Expo Documentation

The following code is added to my project. After adding these codes, the Android notification appears successfully in the foreground. However, there is no effect when I send notifications to iOS devices. Notifications in the background work fine for both iOS and Android.

Notifications.setNotificationHandler({
  handleNotification: async () => ({
    shouldShowAlert: true,
    shouldPlaySound: false,
    shouldSetBadge: false,
  }),
});

When I test the example code in the document on snack, the notification does not appear in the foreground either: Push Notifications - Snack

Hey @turtlefung, can you try adding the error handler to see if somethings is erroring when trying to handle the notification?

I have added the following error handler. The console log function is only executed on Android, but not iOS.

Notifications.setNotificationHandler({
    handleNotification: async () => ({
      shouldShowAlert: true,
      shouldPlaySound: true,
      shouldSetBadge: false,
    }),
    handleSuccess: notificationId => console.log(`Notification ${notificationId} successfully handled.`),
    handleError: (notificationId, error) => console.log(`Notification ${notificationId} wasn't successfully handled.`, error),
  });

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