Reputation: 6960
I need to do a simple NSURLConnection when application goes in background or when ends.
How can I do this ?
I dont' need to download anything or to do any long time operations, I only need to call an API from web service.
Upvotes: 0
Views: 45
Reputation: 5290
If you can only need iOS 7 as a deployment target, you can use the background task API introduced in iOS 7. You can see it in action in this post.
Upvotes: 0
Reputation: 41226
In your applicationWillResignActive use -[UIApplication beginBackgroundTaskWithExpirationHandler:] to start up a background network operation. Be sure to call endBackgroundTask when you're done. The major caution here is that you only have a short amount of time (10 seconds iirc) to finish up.
Upvotes: 1