How iOS gets notifications exactly

Source: Internet
Author: User

iOS get notifications Note the following three places iOS devices receive a push (APNs), when the user clicks Push Notification to open the app, the application will be processed according to the status of the appdelegate to add code in the following two ways to get the APN content

If the app status is not running, this function will be called if Launchoptions contains uiapplicationlaunchoptionsremotenotificationkey indicating that the user clicked the APN notification causing the app to be started to run If it does not contain a corresponding key value, the APP is not started by clicking on the APN, it may be launched directly by clicking icon or other.

(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions; APN Content acquisition: nsdictionary *remotenotification = [launchoptions objectforkey: Uiapplicationlaunchoptionsremotenotificationkey]
Based on the system version of iOS 6 and below, this function will be called if the app status is the foreground or the notification message is clicked It is possible to determine whether the program is running in the foreground through the Appdelegate applicationstate. This situation is handled in this function:

(void) Application: (UIApplication *) application didreceiveremotenotification: (Nsdictionary *) UserInfo; APN content is UserInfo
Based on iOS 7 and later, if you are using the Remote Notification feature of iOS 7, the processing function needs to use the

(void) Application: (UIApplication *) application didreceiveremotenotification: (nsdictionary *) userInfo Fetchcompletionhandler: (void (^) (uibackgroundfetchresult)) Completionhandler; APN content is UserInfo

How iOS gets notifications exactly

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.