Hello,
tldr; relaunch for background uploads isn't working as expected.
I'm testing my code on iPad OS 14.6 and XCode 12.5.1. Background app refresh is ON on my device for my app.
A background file upload is being setup with URLSession. The URL session is created as soon as the app starts up and not lazily created. See URL session configuration below.
I have followed the test instructions as outlined here: https://developer.apple.com/forums/thread/14855, specifically launching my app not via Xcode but from the home screen and adding an exit()
call after the app enters the background in the AppDelegate callback method applicationDidEnterBackground
. The file transfer is initiated before the app enters the background.
Here's the configuration code I'm using:
let configuration = URLSessionConfiguration.background(withIdentifier: <unique_identifier>)
configuration.sessionSendsLaunchEvents = true
configuration.sharedContainerIdentifier = <container group identifier>
configuration.isDiscretionary = false
configuration.timeoutIntervalForResource = 3600 * 24 * 2 // wait for 2 days before timing out connections
urlSession = URLSession(configuration: configuration, delegate:self, delegateQueue: nil)
The file in fact finishes uploading but the app isn't relaunched as one would expect. As soon as I re-open the app from the home screen, I get the requisite callbacks about the upload having completed properly.
In the past when I have tested my code, the method AppDelegate:handleEventsForBackgroundURLSession
used to be called after the upload finishes. That appears to no longer be the case.
Any guidance/help will be hugely appreciated!
Thanks Krishna