I was trying to use the new ios7 background transfer api to upload some photos to a server. what it happened now is 1) we upload the bytes to s3 2) call a service api to 'complete' the upload
i looked at this doc and it seems background NSURLSession doesn't support 'data' task. does that mean i can't do the step 2 in background after the actual upload is done?
For S3 with background task see my answer here
Another good resource is the apple sample code here and look for "Simple Background Transfer"
You have to create an upload task and upload from local file. While your app is running the NSURLSessionTaskDelegate delegate methods will be called on completion specifically at upload completion:
If your app went to the background or even was killed by iOS (and not by the user), your app would be waken up with
And then your NSURLsession delegate method would be called
The way you should build it is as follow, in your appDelegate add
Then in your controller/model class add
If you want a simpler solution than repurposing
NSURLSessionDownloadTask
for your "completed" API call, you can round trip a quick http call during the callback in:-URLSession:task:didCompleteWithError:
put this code into appdelegate.m file
Try this code , hope it will help.
NSURLSessions
has a delegate methodURLSessionDidFinishEventsForBackgroundURLSession
which is called after session completes all its tasks. I believe you should perform an api call out there.