Last active
July 10, 2019 13:14
-
-
Save TsRebornz/093d155b55ababcd36519e02b7956231 to your computer and use it in GitHub Desktop.
BackGroundTaskExample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)applicationDidEnterBackground:(UIApplication *)application | |
{ | |
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | |
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | |
NSLog(@"%s", __FUNCTION__); | |
__block UIBackgroundTaskIdentifier task = [application beginBackgroundTaskWithExpirationHandler:^{ | |
NSLog(@"Expiration handler called %f",[application backgroundTimeRemaining]); | |
[application endBackgroundTask:task]; | |
task = UIBackgroundTaskInvalid; | |
}]; | |
[NSThread sleepForTimeInterval:2.0]; | |
[application endBackgroundTask:task]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment