How does iOS Get Notifications accurately and iOS Get Notifications accurately?

Source: Internet
Author: User

How does iOS Get Notifications accurately and iOS Get Notifications accurately?

For iOS notifications, you must note that the iOS device receives a push (APNs) in the following three places. When you click push notification to open an application, applications are processed according to different States. You need to add code to the following two methods in AppDelegate to obtain the apn content.

If the App status is not running, this function will be called. If launchOptions contains the UIApplicationLaunchOptionsRemoteNotificationKey, the user clicks the apn notification, causing the app to start running; if the corresponding key value is not included, the App is not started because of clicking the apn. It may be started by clicking the icon directly or other.

(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions; // obtain the apn content: NSDictionary * remoteNotification = [launchOptions objectForKey: enabled]
Based on iOS 6 and earlier system versions, if the App status is in the foreground or click the notification message in the notification bar, this function will be called, the applicationState of AppDelegate can be used to determine whether the program is running in the foreground. This situation is handled in this function:

(Void) application :( UIApplication *) application didReceiveRemoteNotification :( NSDictionary *) userInfo; // The content of apn is userInfo
Based on iOS 7 and later versions, if the Remote Notification feature of iOS 7 is used, the processing function must use

(Void) application :( UIApplication *) application didReceiveRemoteNotification :( NSDictionary *) userInfo fetchCompletionHandler :( void (^) (UIBackgroundFetchResult) completionHandler; // The content of apn is userInfo

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.