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