expo-notifications background task stops running once the app is suspended by iOS

This one is driving me bonkers!

  • this is iOS (we dont support Android yet), SDK 45
  • im not using Expo’s push service, I am using node-apn which lets you set content-available
  • My notification objects are correctly set according to Apple’s APNS guidelines:
"push-type": "background",
"content-available": 1,
"priority": 5
...

The notification itself is correct, because sometimes the background task does indeed run.

  • the background task actually works after I manually kill the app, or if I recently backgrounded it.
  • it doesn’t work when the app gets naturally suspended by iOS, from using other apps in a normal way. However, it looks like the app is still being woken up, because in this situation it opens immediately without any splash screen
  • I’ve stripped down the background task to its absolute simplest form:

Outside of the React scope, at the top of App.tsx:

const BACKGROUND_NOTIFICATION_TASK = "background-notification"

TaskManager.defineTask(BACKGROUND_NOTIFICATION_TASK, async (context) => {
    if (context.data.type === "dismiss") {
        // this does run!! even if I manually killed the app, but not if iOS naturally suspended it
        await Notifications.dismissAllNotificationsAsync()
    }
})

Notifications.registerTaskAsync(BACKGROUND_NOTIFICATION_TASK)

Any suggestions? Again, it doesnt seem exactly like Apple is throttling me – besides, plenty of apps like Telegram are extremely reliable with clearing notifications, no matter how much you try to spam it

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