I\'m working on an app that monitors significant location changes in the background. I\'ve been reading all the answers (well, I think all!) about ios4 and the application l
I'd just like to confirm RedBlueThing's answer with some detail.
I now use the following to accomplish this. bgTask is declared as UIBackgroundTaskIdentifier
bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:
^{
[[UIApplication sharedApplication] endBackgroundTask:bgTask];
}];
// Now call methods doing network activity
// ...
// WHEN I KNOW THE LAST ACTION HAS COMPLETED USE THIS BLOCK OF CODE
if (bgTask != UIBackgroundTaskInvalid)
{
[[UIApplication sharedApplication] endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}
Hope this helps out since I see quite a few people looking at the question.