IOS push services

Source: Internet
Author: User

IOS push services

Apple Push Notification Service (APNS) is a common interaction method in iOS applications.

APNS relies on one or more system resident processes to take over message pushing for all applications. Therefore, APNS can be seen as independent from applications and communication between devices and Apple servers, rather than application provider servers.

Unlike Android, Android is more like a traditional desktop system. Each app that needs to be pushed in the background has its own background process to communicate with its own servers and exchange data.

In addition, Android also has GCM (Google Cloud Message) similar to APNS, which is optional and not mandatory for developers.

So you may see the difference. When the message push mechanism of iOS was launched, it was a brand new solution (called a platform in the platform). The application itself cannot have resident background processes, the system costs less, memory usage less, and power consumption

Less (put more computing and resource overhead on the cloud, not on the device side ). However, Android features a high overhead, which is more stable and fast, but not obvious.

How APNS works:

1. The App requests the device whether to allow the use of the notification service.

2. the device will carry the App name to the push Notification Server of Apple to send a request to accept the Notification Service

3. The apple push notification server sends the deviceToken and App names to the device.

4. The App sends deviceToken and other information to the server that stores the notification content.

5. Our own server that stores the notification content sends the deviceToken and notification content to the Apple push notification server.

6. The apple push Notification Server finally delivers the notification content to the device according to the deviceToken

APNS usage:

1. register the appid in https://developer.apple.com/account/ios/identifiers/bundle/bundlelist.action

2. In https://developer.apple.com/account/ios/certificate/certificateList.action? Type = register APNS push Certificate in development download and install

3. Generally, APNS is performed in AppDelegate.

1) first, you must register the notification service. Because the method for registering the push notification after iOS8.0 is changed, you must determine the system version of the device.

// Register the Notification Service

If ([UIDevice currentDevice]. systemVersion. floatValue <8.0 ){

[[UIApplication sharedApplication] registerForRemoteNotificationTypes :( UIRemoteNotificationTypeBadge |

UIRemoteNotificationTypeSound |

UIRemoteNotificationTypeAlert)];

} Else {

UIUserNotificationSettings * settings = [UIUserNotificationSettings settingsForTypes :(

UIRemoteNotificationTypeBadge |

UIRemoteNotificationTypeSound |

Uiremotenotiftypetypealert) categories: nil];

[Application registerUserNotificationSettings: settings];

[Application registerForRemoteNotifications];

}

4. Method of successful registration call

-(Void) application :( UIApplication *) application didRegisterForRemoteNotificationsWithDeviceToken :( NSData *) deviceToken

5. Method for calling failed Registration

-(Void) application :( UIApplication *) application didFailToRegisterForRemoteNotificationsWithError :( NSError *) error

6. How to trigger the PUSH message

-(Void) application :( UIApplication *) application didReceiveRemoteNotification :( NSDictionary *) userInfo

[UIApplication sharedApplication]. applicationIconBadgeNumber

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.