Expiration Handler

The expiration handler for a background task will get called if the operating system decides the app has run out of time and/or resources and needs to be shut down. The expiration handler will get called on the main thread before the app is about to be shut down. Not much time is provided (at most it is a few seconds), so the handler should do a minimal amount of work.

__block UIBackgroundTaskIdentifier bTask =[[UIApplication sharedApplication]beginBackgroundTaskWithExpirationHandler:^{    NSLog(@"Background Expiration Handler called.");    NSLog(@"Counter is: %d, task ID is %u.",counter,bTask);    [[UIApplication sharedApplication]    endBackgroundTask:bTask];    bTask = UIBackgroundTaskInvalid ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.