Remote push for IOS development and ios development
1. Implementation Principle
Principles of remote push:
In the figure, Provider refers to the ios app server, and APNS refers to the Apple Server. The process is as follows: first, the application server packs the message to be sent and sends the ID of the target iphone to APNS. Second, APNS searches for the iphone with the corresponding identifier in its registered Push Service iphone list, and sends the message to the iphone. Third, the iphone transmits the sent message to the corresponding application, and the push notification is displayed according to the settings.
2. Specific Operation Procedure
(1) Procedure
[1] Application Registration message push
[2] ios requests deviceToken from the Apple Server. The application accepts deviceToken.
[3] The application sends the deviceToken to the server (the server of the ios program)
[4] The certificate creation process is as follows:
(2) create a certificate, generate a certificate file, and obtain the password of the Certificate file.
(3) Remote push Program Implementation
3. Practice
3.1 create a pem file Certificate
Baidu cloud push registration needs to import the development certificate and upload the certificate (pem Format File) in the application configuration)
Openssl pkcs12-in CertificateName. p12-out CertificateName. pem-nodes
Note: when using the terminal configuration, you must correctly write the p12 file address (directly drag the file to the terminal for automatic generation) and write the folder address generated by the generated pem file, otherwise, you cannot find the generated pem file.
3.2 application configuration
Only after the certificate is imported can we get the permission to register the Baidu cloud PUSH Service (get the APPKey to register Baidu cloud push)
3.3 import Baidu cloud push SDK
3.4 what is required for SDK configuration: configurator Identifier
After 3.5, we have completed the configuration of Baidu cloud push.
4. Code: (I will not write the relevant code in Baidu cloud push. Let me talk about the points we need to pay attention to in the DEMO to ensure that we have successfully established APNS)
4.1: Fill in the following red area for the AppKey obtained after the application configuration is complete. If it is in the development status, enter BPushModeDevelopment. When going online, change the development status to the publishing status BPushModeProduction.
4.2: we send the hardware number of our mobile phone to a third party to bind the mobile phone number. (If the mobile phone number is successfully bound, a message is returned)
4.3 after successful binding, it means that we have successfully established APNS and can implement remote push.