Skip to content

Instantly share code, notes, and snippets.

@TsRebornz
Last active July 10, 2019 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TsRebornz/093d155b55ababcd36519e02b7956231 to your computer and use it in GitHub Desktop.
Save TsRebornz/093d155b55ababcd36519e02b7956231 to your computer and use it in GitHub Desktop.
BackGroundTaskExample
- (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