This article focuses on some of the most commonly used callback methods in the Uiapplicationdelegate call timing.
To help you decide which methods to put down to which callback to implement.
1.– (void) applicationdidfinishlaunching: (uiapplication *) application;
This method has basically been deprecated and replaced by a 2nd method instead.
2.– (BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions NS_ Available_ios (3_0);
This callback is called when the application starts (not including when it goes to the foreground in the background). Launchoptions is the startup parameter, and if the user launches the app by clicking on the push notification, this parameter stores some information about the push notification.
3.– (void) applicationdidbecomeactive: (uiapplication *) application;
Restart any tasks this were paused (or not yet started) while the application is inactive. If the application is previously in the background, optionally refresh the user interface.
This method is called when the application is launched completely, or when it is fully activated in the background to the foreground. If the application is previously running in the background, you can choose to refresh the user interface.
4.– (void) applicationwillresignactive: (uiapplication *) application;
Sent when the application are about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as a incoming phone call or SMS message) or when the US Er quits the application and it begins the transition to the background state.
Use the This method to the pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
This method is called when an application is active to an inactive state from an active state. This can result in some types of temporary interrupts, such as incoming phone calls or SMS messages. Or when the user exits the application, it starts transitioning to the background state. Use this method to pause an in-progress task, disable the timer, and reduce the frame rate of OpenGL es. The game should use this method to pause the game.
The timing of the call may be the following: Lock screen, press the Home key, next to the status bar, double-click the Home button pop-up college athletics, and so on.
5.– (BOOL) Application: (UIApplication *) application Handleopenurl: (nsurl *) URL;
'll be deprecated at some point, please replace with application:openURL:sourceApplication:annotation:
This method is no longer supported and may be removed in a later release. The following 6th method is recommended instead of
6.– (BOOL) Application: (UIApplication *) application OpenURL: (nsurl *) URL sourceapplication: (NSString *) sourceapplication annotation: (id) annotation Ns_available_ios (4_2);
No EQUIV. Notification. Return NO If the application can ' t open for some reason
When the user launches the app from another app, the method is called back, and the URL parameter is passed when the other app calls the OpenURL: method.
7.– (void) applicationdidreceivememorywarning: (uiapplication *) application;
Try to clean up as much memory as possible. Next step is to terminate app
This method is called when the app is running out of available memory, and in this method, you should try to clean up the memory that might be freed. If this is not possible, you may be forced to quit the app.
8.– (void) Applicationwillterminate: (uiapplication *) application;
Called when the application are about to terminate. Save data if appropriate. See also Applicationdidenterbackground:.
When the application exits, and the process is about to end, it will be transferred to this method, generally rarely actively transferred to, more memory is not enough to be forced to, we should do some data storage operations in this method.
9.//One of these'll be called after calling-registerforremotenotifications
-(void) Application: (UIApplication *) application Didregisterforremotenotificationswithdevicetoken: (NSData *) Devicetoken Ns_available_ios (3_0);
-(void) Application: (UIApplication *) application Didfailtoregisterforremotenotificationswitherror: (NSError *) error Ns_available_ios (3_0);
When the client registers a remote notification, the above two methods are recalled.
If successful, the callback is the first, and the client takes the Devicetoken out to the server, which is used when the push message is sent.
If it fails, then the second callback, you can see the reason for the failure from the error parameter.
Note: Registering remote notifications uses the following methods:
Uiremotenotificationtype t=uiremotenotificationtypebadge| Uiremotenotificationtypealert| Uiremotenotificationtypesound; [[UIApplication sharedapplication] registerforremotenotificationtypes:t];
10.– (void) Application: (UIApplication *) application didreceiveremotenotification: (nsdictionary *) UserInfo NS_ Available_ios (3_0);
When the app is running in the foreground, it is called back when the remote notification is received.
When the app is in the background state, clicking the push message launches the app and also calls back the method.
11.– (void) Application: (UIApplication *) application didreceivelocalnotification: (Uilocalnotification *) Notification Ns_available_ios (4_0);
This method is tuned when the app receives local notifications, similar to the one above.
If it is called directly in the foreground running state, if it is in the background state, when the click Notification starts, it will also callback this method
local notification visible another article: http://bluevt.org/?p=70
12.– (void) Applicationdidenterbackground: (uiapplication *) application Ns_available_ios (4_0);
Use the This method to release the shared resources, save user data, invalidate timers, and store enough application state info Rmation to the restore your application to the it is terminated later.
If your application supports background execution, this method is called instead of Applicationwillterminate:when the User quits.
This method is called when the user is transferred from the front state to the background. After you use this method to release the resource share, save the user data, the invalid timer, and store enough application state information to be terminated, the application is restored to its current state. If your application supports running in the background, this method is called, otherwise call Applicationwillterminate: the user exits.
13.– (void) Applicationwillenterforeground: (uiapplication *) application Ns_available_ios (4_0);
Called as part of the transition from the background to the inactive state; Here's can undo many of the changes made on entering the background.
This method is called when the app is in the background state and the foreground run state will be moved.
If the app is not in the background state and is started directly, this method will not be recalled.
Several commonly used callback call timing in Appdelegate