The Apple push notification service (Apple push Notification service) is referred to as APNs. is a very common way of interacting with iOS apps.
APNs relies on one or several system-resident processes to take over the message push of all applications, so it can be viewed as being independent of the application and is the communication between the device and the Apple server, not the application's provider server.
Unlike Android, Android is more like a traditional desktop computer system. Each app that requires a background push has its own separate background process to communicate with its servers and exchange data.
In fact, Android also has a similar APNS GCM (Google Cloud Message), the developer is optional, non-mandatory.
So you probably see the difference, the IOS message push mechanism is a new solution (called Platform in the platform), the application itself can not have a permanent background process, the system has less overhead, less memory usage, power
Less (Put more computing and resource overhead in the cloud, not the device side). While the features of Android, although the cost is large, the advantages are more stable and fast, but not obvious.
How the APNs works:
1. The app asks the device if it is allowed to use the notification service
2. The device carries the app name to the Apple push notification server to send a request to allow the notification service to be accepted
3. Apple push Notification server sends Devicetoken and app names to the device
4. The app sends information such as Devicetoken to our own servers that store notification content
5. Our own servers that store notification content send devicetoken and notification content to the Apple push notification server
6. Apple push Notification Server finally sends the notification content according to Devicetoken to the device
Use of APNs:
1. Register the app's ID in https://developer.apple.com/account/ios/identifiers/bundle/bundleList.action
2. Register APNs push Certificate in https://developer.apple.com/account/ios/certificate/certificateList.action?type=development download and install
3. General APNs are carried out in the appdelegate.
1). First to register the notification service, because the iOS8.0 after the push notification registration method changes, so the system version of the device to determine
Registration Notification Service
if ([Uidevice Currentdevice].systemversion.floatvalue < 8.0) {
[[UIApplication Sharedapplication] registerforremotenotificationtypes: (Uiremotenotificationtypebadge |
Uiremotenotificationtypesound |
Uiremotenotificationtypealert)];
} else {
uiusernotificationsettings* settings = [uiusernotificationsettings settingsfortypes: (
Uiremotenotificationtypebadge |
Uiremotenotificationtypesound |
Uiremotenotificationtypealert) Categories:nil];
[Application registerusernotificationsettings:settings];
[Application registerforremotenotifications];
}
4. How to register a successful call
-(void) Application: (UIApplication *) application Didregisterforremotenotificationswithdevicetoken: (NSData *) Devicetoken
5. Methods for registering failed calls
-(void) Application: (UIApplication *) application Didfailtoregisterforremotenotificationswitherror: (NSError *) error
6. How to trigger the delivery of push messages
-(void) Application: (UIApplication *) application didreceiveremotenotification: (nsdictionary *) userInfo
Another: Push in the icon often appear on the corner mark [UIApplication Sharedapplication].applicationiconbadgenumber
Points about the push service for iOS