Created
March 5, 2016 21:53
-
-
Save ramakser/6d9c7990e19aa669b555 to your computer and use it in GitHub Desktop.
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
var backgroundUpdateTask: UIBackgroundTaskIdentifier = 0 | |
func applicationWillResignActive(application: UIApplication) { | |
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | |
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. | |
self.backgroundUpdateTask = UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHandler({ | |
self.endBackgroundUpdateTask() | |
}) | |
} | |
func endBackgroundUpdateTask() { | |
UIApplication.sharedApplication().endBackgroundTask(self.backgroundUpdateTask) | |
self.backgroundUpdateTask = UIBackgroundTaskInvalid | |
} | |
func applicationWillEnterForeground(application: UIApplication) { | |
self.endBackgroundUpdateTask() | |
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment