1. Push process:
Provider: our own backend server;
APNS: Apple's message Push server
(1) When provider has a message to push to the phone, first send the message and Devicetoken fields to APNs
(2) APNs find the device in the list of registered devices and push the message to the device;
(3) iOS delivers messages to the application, or displays notifications, etc.;
2. Registration-Push the full process:
(1) App registration message push;
(2) iOS to APNs request Devicetoken,app get Devicetoken;
(3) The app sends Devicetoken to the server;
(4) If a message is notified, the server sends the message together with Devicetoken to APNs;
(5) APNs find the device and push the message to the device;
3. Push Certificate generation Process:
(I have all the new certificate here, if you can ignore, note the following steps to save the file to the same directory, easy to confirm and use);
--mac
(1) Using keychain--Keychain Access--Certificate assistant--Request a certificate from a certificate authority, fill out a mailbox, select Save to disk, will produce the CSR file;
--developer
(2) Create AppID in identifiers, note that the explicit APP Id,bundle ID cannot contain wildcards, must be a definite ID; select push notifications;
(3) Create a development certificate in certificates, select iOS App development, select AppID, import the previously generated CSR file, generate download Download certificate;
(4) Create a push certificate in certificates, select the app push Notification service SSL (Sandbox), also select AppID, import the previously generated CSR file, generate download Download certificate;
(5) Provising profiles Create a profile, select the iOS App development, select the previous AppID, select the previous development certificate, select the included device, enter a name, and generate download download;
--mac
(6) Double-click the certificate generated in the (3) (4) step, double-click the provising profile, configure code Signing in Xcode, select the corresponding developer and profile;
(7) in the keychain found (4) in the certificate Apple devlopment IOS Push services:xxxx, click on the arrow to expand, click on the private key, right export, enter the password such as: hello123, save, such as TESTPUSH.P12;
(8) Confirm the following file, this time the catalogue file contains, Certificatesigningrequest.certsigningrequest,ios_development.cer,aps_ DEVELOPMENT.CER,TESTPUSH.P12;
(9) Testpush.p12 and aps_development.cer are generated PEM files, note that the generation of TESTPUSH.P12 corresponding PEM time, the need to enter a password, in order to avoid confusion, the use of hello123;
OpenSSL X509- in aps_development-3. Cer-inform der-out Pushchatcert.pem
OpenSSL pkcs12-nocerts-out Pushchatkey.pem- in TESTPUSH.P12
Enter Import Password:
MAC verified OK
Enter PEM Pass Phrase:
Verifying-enter PEM Pass Phrase:
(10) Merging two PEM files into a PEM file;
Cat Pushchatcert.pem Pushchatkey.pem > Ck.pem
(11) test whether you can telnet to Apple server;
2195
17.110. 226.164 ... Connected to Gateway.sandbox.push-'^]'. ^]
(12) Test with the generated certificate to establish SSL secure connection to the server, return a lot of information, indicating success;
OpenSSL s_client-connect gateway.sandbox.push.apple.com:2195-cert Pushchatcert.pem-Key Pushchatkey.pem
Enter Pass phrase forPushChatKey.pem:CONNECTED (00000003) Depth=1/c=us/o=entrust, Inc./ou=www.entrust.net/rpa is incorporated by reference/ou= (C) theEntrust, inc./cn=entrust certification Authority-l1cverify Error:num= -: Unable to get local issuer certificateverify return:0---Certificate Chain0S:/c=us/st=california/l=cupertino/o=apple inc./cn=gateway.sandbox.push.apple.com I:/c=us/o=entrust, Inc./ou=www.entrust.net/rpa is incorporated by reference/ou= (C) theEntrust, inc./cn=Entrust ....... Key-arg:none Start Time:1458041365Timeout: -(sec) Verify return code:0(OK)---
(13) Adding push-related code to the appdelegate.m of the project;
(14) Put the CK.PEM on the server, the server creates the message push service, the test is successful;
Thank:
Https://developer.apple.com
http://blog.csdn.net/shenjie12345678/article/details/41120637
Http://www.cocoachina.com/industry/20130321/5862.html
iOS push principle