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