Background tasks completing without notification
Background tasks completing without notification
- Subject: Background tasks completing without notification
- From: Scott Hancher <email@hidden>
- Date: Tue, 04 Mar 2014 15:45:13 -0800
I'm currently working on out-of-process upload support within our application. We're uploading a file, which is optionally broken down into chunks uploaded one chunk after another. Each chunk instantiates an NSURLSessionUploadTask through uploadTaskWithRequest:fromFile:. To test out the out-of-process support, our TEST app exits the app after it begins uploading a chunk. If a chunk completes after the app exits, it's relaunched by the system and the system calls application:handleEventsForBackgroundURLSession:completionHandler: on my application delegate as expected.
However, sometimes when I launch the app explicitly and don't get a call to application:handleEventsForBackgroundURLSession:completionHandler:, I can't seem to figure out how to check on the status of my out-of-process upload. I recreate an NSURLSession with the same session identifier that I persisted from the previous launch. Typically, when I do this, I get a delegate call to URLSession:task:didCompleteWithError: almost immediately. However, sometimes I don't. If I call NSURLSession's getTasksWithCompletionHandler:, no tasks are returned to the completion handler.
How can I check on the actual state of the upload task on relaunching my app? I've added logic that assumes a failed upload if on re-launch getTasksWithCompletionHandler: returns 0 tasks and I don't get a callback to NSURLSession delegate within a short timeframe. I'm assuming there's an alternative means.
Thank you,
++Scott.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden