Reputation: 4077
If an app relies on background fetch and needs to do some handling if the fetched data is not empty, does it make sense to do:
1) fetch data with background NSURLSession (using backgroundSessionConfigurationWithIdentifier)
2) handle data in a background task (using beginBackgroundTask)
Since the system gives 30 seconds to complete a background fetch, it seems like neither #1 or #2 are really needed. The documentation (https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html) does not explicitly say anything on whether these techniques can be combined, so I just seek for confirmation.
Upvotes: 3
Views: 2152
Reputation: 4077
All right, after some digging with backgrounding I think I can at least partially answer my own question for those who still wonder.
Background Fetch with Background-configured NSURLSession
The app has only 30 seconds to complete download during background fetch. If an entire download flow takes time less than this limit, it is fine to use default URLSession (without background configuration).
However if the resource being loaded is large, it makes perfect sense to spend given 30 seconds (or less) for the prep and initiate URLSession with background configuration. Once configured, your NSURLSession object will seamlessly hand off download tasks to the system, so that resource transfer will not be a subject of 30 second completion limit.
Background Fetch with Background Tasks
Upvotes: 6