Tells the delegate that the app is now in the background.
SDKs
- iOS 4.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- UIKit
Declaration
- (void)applicationDidEnterBackground:(UIApplication *)application;
Parameters
application
Your singleton app object.
Discussion
Use this method to release shared resources, invalidate timers, and store enough app state information to restore your app to its current state in case it is terminated later. You should also disable updates to your app’s user interface and avoid using some types of shared system resources (such as the user’s contacts database). It is also imperative that you avoid using OpenGL ES in the background.
Your implementation of this method has approximately five seconds to perform any tasks and return. If you need additional time to perform any final tasks, you can request additional execution time from the system by calling begin
. In practice, you should return from application
as quickly as possible. If the method does not return before time runs out your app is terminated and purged from memory.
You should perform any tasks relating to adjusting your user interface before this method exits but other tasks (such as saving state) should be moved to a concurrent dispatch queue or secondary thread as needed. Because it's likely any background tasks you start in application
will not run until after that method exits, you should request additional background execution time before starting those tasks. In other words, first call begin
and then run the task on a dispatch queue or secondary thread.
The app also posts a UIApplication
notification around the same time it calls this method to give interested objects a chance to respond to the transition.
For more information about how to transition gracefully to the background, and for information about how to start background tasks, see App Programming Guide for iOS.