1. Principle of implementation
The principle of remote push:
The provider in the figure refers to the iOS program's server, APNs refers to the Apple server. The process is this, first, the application of the server to send messages, the purpose of the iphone's logo package, sent to APNs, and second, APNs in their own registered push service iphone list, find the corresponding identifier of the iphone, and send the message to the iphone; third , the iphone sends the message to the appropriate application and pops up the push notification as set.
2. Specific Operating Procedures
(1) Operation procedure
"1" Application registration message push
"2" ios looking for Apple server to Devicetoken. Application accepts Devicetoken
The "3" application sends Devicetoken to the server (the iOS program's server)
"4" regardless of whether the iphone client and the Apple server, or the terminal server and the Apple server are required to connect through the certificate, the following is the production process of the certificate:
(2) Make the certificate, generate the certificate file, and get the password of the certificate file
(3) Remote Push program implementation
3. Actual combat
3.1 Making a PEM file certificate
Baidu Cloud Push registration needs to import the development certificate and upload certificate in the application configuration (PEM format file)
OpenSSL pkcs12-in certificatename.p12-out certificatename.pem-nodes
Note: When using the terminal configuration to correctly write P12 file address (directly to the file down terminal automatically generated), you must write the generated PEM file generated folder address, no you can not find the generated PEM file
3.2 Application Configuration
Only after the import of the certificate we can obtain the registration of Baidu Cloud push service rights (to be registered Baidu Cloud push Appkey)
3.3 Import Baidu Cloud Push SDK
3.4 What you need to configure the SDK: Configurator identifier
3.5 After this step, we have completed the configuration of Baidu Cloud push.
4. Code: (Baidu Cloud push contains related code I will not write it all.) I'm going to talk about what we need to pay attention to in the demo to make sure we apns the success.
4.1: We will fill in the following red area after the application configuration is completed, if it is development status, we will fill in the Bpushmodedevelopment, appkey the development status to the release status Bpushmodeproduction
4.2: We send our phone's hardware number to a third party to bind the phone (the binding will return successfully)
4.3 After the successful binding means that we have successfully established the APNS, we can achieve remote push
Remote push for iOS development