My app needs to upload data in the background, because there's potentially too much to complete while the app is in the foreground. It's getting close to working:
- I'm using a background session via URLSessionConfiguration.background(withIdentifier: "name")
- I start an upload task with this session
- I put my app in the background and then launch other apps to get iOS to terminate mine due to memory pressure
- I wait while the upload completes
Later on, the app launches in the background, and
- I get the expected call to application(_:, handleEventsForBackgroundURLSession:, completionHandler:)
- I re-create my session as described above
- I get a callback to urlSessionDidFinishEvents(forBackgroundURLSession:)
So far so good, but I also need to be able to get some information that the server returns. I thought I could look up tasks on the session object and use those, but both getAllTasks(completionHandler:) and getTasksWithCompletionHandler(_:) give me empty arays for all closure arguments.
What do I need to do to get the completion status for those tasks? Why can't I get the tasks from the session?
iOS 10.2.1, iPhone 6