Search code examples
iosswiftbackgroundbackground-task

`BGAppRefreshTask` vs `BGProcessingTask` understanding timing


I'm trying to understand the distinction between BGAppRefreshTask and BGProcessingTask where for processing Apple's docs say for a process that “takes minutes” whereas refresh they say for a “short request task.” I am iterating through workouts in HealthKit which takes under a minute, so should I be using BGAppRefreshTask?


Solution

  • The BGAppRefreshTask has a time limit of 30 seconds. So if you can't guarantee the task will take less than that time, the BGProcessingTask may probably more appropriate.

    This was noted in the WWDC 2019 Session 707 Advances in App Background Execution. The relevant time index is: 18:51