IOS click notification in the notification bar to enter the program trigger event, ios trigger

Source: Internet
Author: User

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.



 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.