Simple principle and configuration of IOS push service

Source: Internet
Author: User
Tags ssl certificate

Recent projects need to use the iOS push function, in the process of configuring the push function encountered some unclear, after looking at the data and thinking, there is a preliminary understanding, the following to comb, our server is using the Facebook parse.

The complete push process is this, where the server passes the information to the APNs (Apple Push Notification Service) and the APNs push the information to the target device.

Server--apns

The server and APNs communicate through the SSL (Secure Sockets Layer) protocol, the simple reason should be that Apple's push server must not casually accept the external push request, only through its authentication can be, So our service-side program needs an SSL certificate from Apple. How is this certificate obtained? In a few steps:

1. Generate an SSL certificate request file Certificatesigningrequest.certsigningrequest

    • Open Keychain Access
    • Select Keychain Access > Certificate Assistant > Request a Certificate from a Certificate authority ...
    • Fill in email

2. Upload the SSL certificate request file to Apple Developer Member Center to obtain a true SSL certificate, we assume that the app ID has been created

    • In Member Center select certificates, Identifiers & Profiles, select Identifiers, enter the appropriate app ID, select Settings.

    • Swipe down on the page to Push notifications, where we can create the SSL certificate that will be configured on the server, the process of developing the certificate and issuing the certificate request is the same, here we take the development certificate as an example.

    • On the next page click on continue, we will be asked to upload the certificate Signing request (CSR) file that was generated earlier, that is, certificatesigningrequest.certsigningrequest.
    • Click Generate after uploading, the SSL certificate is generated, we need to download it locally, there is a file aps_development.cer.

3. Configure the SSL certificate on the server side

Although the local already has the server side required SSL Certificate Aps_development.cer, but it does not directly to the server side, but also need a little operation, how to process see the following process.

    • Double-click SSL Certificate Aps_development.cer, which is automatically imported into keychain, and observe the changes in access before and after the double-click Keychain.
    • In the "My Certificates" category in keychain Access, right-click the Import SSL certificate (the bundle ID named Apple Development IOS Push Services:app) and select Export in the diagram.
    • When you select Export, a page appears so that I can export the certificate in. p12 format, which is required by the server side, at least for parse. P12. * Note *, make sure that the "My Certificates" category is selected in the previous step, otherwise in this step. The P12 format is disable. Finally get the server side of the "Apple visa", according to the server-side configuration requirements to configure it, in the parse only need to upload this. p12 file.

Now that the server-side--apns has been opened, we continue to consider communication between the apns--devices.

apns--Device (device distributes push information to app)

How does APNs know which device or devices to push the server to? It is clear that the server side has told APNs the target device, and it is understood that APNs requires the server to tell it in JSON (JavaScript Object Notation) format to the device ID collection of the target devices, and then sends the push information to the appropriate device. The push information is to the device, and the device then assigns the push information to the specific app according to the content of the push message. As a result, the app installed on the device also needs something that can be Yue Heyue, something that is certainly provided by Apple Developer Member Center.

1. Create Provisioning Profile

    • Select Certificates, Identifiers & Profiles in Member Center, then click "+" on the top right of the provisioning Profiles page.
    • Step by step will eventually let us fill in a provisioning profile name and then generate the file.
2. Configure the App
    • Download provisioning profile to local, double-click, Auto Import to Xcode.
    • Set code signing in Xcode.

Here, the app's Yue Heyue work has been done, the server-side--apns--device (accurate is the app) all get through, the rest is the code level of work. Finally, to summarize the configuration of Apple push, want to implement SERVER--APNS--APP push communication, let APNS know server and app, so need two objects, One is the SSL certificate to the server (the final form is. p12), and the provisioning profile for the app, both of which must be applied to Apple, is the purpose of the above series of processes.

Also, add a little bit about the Certificatesigningrequest.certsigningrequest file, which is the certificate request file that we applied to Apple for the certificate, which can be generated in keychain access, then , do you want to generate it once per production certificate? No This certificatesigningrequest.certsigningrequest file may contain only a few Mac device information, timestamps, and so on, multiple certificatesigningrequest.certsigningr generated on the same Mac The Equest file may be just a timestamp different, the other is the same, so it only needs to generate one, and then do a variety of SSL certificates can be used.

Simple principle and configuration of IOS push service

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.