APNS remote PUSH notification PUSH deviceToken and apnsdevicetoken

Source: Internet
Author: User
Tags notification center

APNS remote PUSH notification PUSH deviceToken and apnsdevicetoken
The server pushes messages to the client: when the application is pushed to the background, or it is not running at all (our code is powerless)
In this case, the application wants to interact with the user (the traditional approach is not possible)
PushAPNS: Apple Push Notification ServiceDeviceToken: Indicates an application on an iPhone.
1. (You must confirm that you need to receive the PUSH message) register the remote notification center and obtain the 64-Bit String deviceToken from APNS.Register remote notification center
[[UIApplication sharedApplication] registerForRemoteNotificationTypes :( UIRemoteNotificationTypeBadge | uiremotenotiftypetypealert | uiremotenotiftypetypesound)];
Parameter: uiremotenotiftypetypebadge // badge of the application
UIRemoteNotificationTypeSound // push the prompt sound

UIRemoteNotificationTypeAlert // content in the prompt box


2. APNS returns deviceToken (the proxy method is used). 1) The deviceToken is obtained successfully, and the system callback-(void) application :( UIApplication *) application didRegisterForRemoteNotificationsWithDeviceToken :( NSData *) deviceToken; 2, system callback-(void) application :( UIApplication *) application didFailToRegisterForRemoteNotificationsWithError :( NSError *) error;
3. iPhone uploads deviceToken to the server (POST) for example: deviceToken: <c389e769 d6ddb7d5 a783a015 ff553d90 5b1e04e2 6fa71ec7 f0aa52ab 4bdcc660> 1. process strings, remove spaces, and <> 2. get a 64-bit string and post it to the server 4. the server sends the pushed message + deviceToken + (SSL & privace key (two generate one file) to APNS 5. (After verification is passed) APNS sends the message to the iPhone 6. the user clicks push notification, and the system calls back (set the badge to zero in this method)-(void) application :( UIApplication *) application didReceiveRemoteNotification :( NSDictionary *) userInfo;
Parameter: userInfo: Content pushed + sound pushed + badge label 1) set badge @ property (nonatomic) NSInteger applicationIconBadgeNumber; certificate required for pushing: this certificate is one copy for the client and one copy for the server (the client server)
The server and client push certificate must be consistent

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.