Reputation: 14006
I'm writing an app with an image upload feature. Right now I'm using NSURL POST like: 125306.
When the app is closed as far as I can tell all of the uploads abort and the threads die. Is there
1) a way to make these upload threads persist when the app is no longer in the foreground?
2) an iPhone OS service that will accept requests to queue a job and run it in a mode managed by the OS?
Upvotes: 2
Views: 3360
Reputation: 89242
EDIT: This is an old answer from 2009. Current iOS (2016) has background URL tasks. See NSURLSessionUploadTask.
Original answer follows:
You aren't allowed to run in the background on an iPhone (as per Apple's Guidelines). Your app will be rejected from the AppStore if you do.
Upvotes: 9
Reputation: 4182
After app suspending you only have ~10 mins to do the job. You should make a background process thread when app is suspended. And you have no garanties that os will keep app alive. It depends on process complexity.
Upvotes: 0
Reputation: 75077
As noted, you cannot have a background process - a good compromise would be to resize the photo down to a size that could be transferred in a reasonable amount of time (user configurable would be best), and display an activity indicator of some kind so the user would know the upload was in progress.
An even better solution would be the resize, along with a progress indicator giving the percentage currently uploaded - but that involves some custom low-level HTTP code.
Upvotes: 1
Reputation: 12177
As has been failry well documented, no background processes are allowed using the SDK.
Upvotes: 4