Handling incoming notifications when the app is not in the foreground

Im trying to test when notification is received while the app is backgrounded, following this documentation

const BACKGROUND_NOTIFICATION_TASK = 'BACKGROUND-NOTIFICATION-TASK';

TaskManager.defineTask(BACKGROUND_NOTIFICATION_TASK, ({ data, error, executionInfo }) => {
  console.log('Received a notification in the background!');

});

Notifications.registerTaskAsync(BACKGROUND_NOTIFICATION_TASK);

And I doesn’t work !!!

Can you handle the tapped notification when app was killed? I am using addNotificationResponseReceivedListener to handle tapped notification and redirect the user to appropriate screen (based on the type of notification). But the listener only works when the app is in foreground or background. If it was killed and launched due to tapping the notification, then the listener doesn’t get called.

1 Like

May you guide me how can I make push notification works in backround do I have add priority: ‘max’ in await Notifications.scheduleNotificationAsync because it works only in foreground !!

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