IOS click notification in the notification bar to enter the program trigger event, ios trigger
When you click the notification in the notification bar to enter the program, the method in App Delegate will be triggered, which can be divided into the following two situations:
1. When the program is not started (that is, there is no process in the taskbar at the bottom:
In this case, clicking the notification in the notification bar will trigger the following method:
-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions
The launchOptions parameter must be processed as follows:
NSDictionary * pushNotificationKey = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
The pushNotificationKey is the data pushed from the server. You can use the key-Value Pair method to read the additional parameters transmitted by the server.
The application has not been loaded. If you click the display button of the notification, the didfinishlaunchingwitexceptions will be called and the didReceiveRemoteNotification method will not be called.If you click the close button of the notification and then click the application, only the didfinishlaunchingwitexceptions method is called.
2. The program has been started:
If the program has been started and resides in the memory, whether the program is in the Foreground (Foreground) or in the Background (Background), clicking the notification in the notification bar will trigger the following method:
-(Void) application :( UIApplication *) application didReceiveRemoteNotification :( NSDictionary *) userInfo
The userInfo parameter is the data pushed by the server and is also read using key-value pairs.
If you click Close and then click application, neither of the above two methods will be called. You can only use applicationWillEnterForeground or applicationDidBecomeActive to check whether a notification is sent based on the badge in the sent notification, and then send a request to obtain data.