This article will take you through a simple Iosapp message push tutorial, including XCode6, IOS8, and Apple Developer Center How to register the app, request a certificate, and download the configuration profile, and I believe many people who are just beginning to contact iOS will want to know. (PS: Read a bit on the Internet although there are a lot of good tutorials to talk about push, I also look at the steps to learn, but the time of these tutorials is last year or earlier, not very suitable for beginners to guide)
The first part
The first step, of course, is to introduce the Apple push mechanism (PS: In fact, every tutorial has), first of all, to see an Apple's APNS to explain its push to make a schematic.
Provider is a server that sends push messages to your mobile app, while APNs (Apple push Notification Service) is an Apple messaging push server. Your local server when you need to push a message to the app, first send the message to the Apple push server, and then by the Apple push server to send the message to the phone that installed the app.
Let's look at an explanation chart:
Based on the logic I'll explain to you:
1. Your iOS app needs to register for the APNS message push feature.
2. When the Apple APNs push receives the registration message from your app, it will return a bunch of device tokens to you (very important)
3. Pass the device token received by the app to your local push server.
4. When you need to push a message for the app, your local push server will send the message, along with the device token, to Apple's APNs service.
5.APNS then pushes the message to the destination iphone
Part II
1. Issuing certificates from a certification authority
Open your Mac Keychain access: Then click Keychain to access
It will then pop up a window
User email information
Just fill in the name of your Apple Developer account (should be a message name), click on the Save to Disk option, click Continue, show the following
Click Save, the file name is: Certificatesigningrequest.certsigningrequest then put him in a folder we named Push!
Part III
Visit the Apple Developer website: https://developer.apple.com/
Select the Membercenter option, go to the landing page, log in with your Apple developer account, and the page will automatically jump in a while.
Click the Red selected section
Content for the next steps.
Select the Certificates option, set the certificate, first explain
The function of the development option is used as the name of the certificate for development use, the production option is used to publish the product use, the name is unfamiliar is not, the previous developer page is not this option, it may be Apple changed him, It is more understandable to use this name (literally the product). Two options The steps to generate the certificate are the same, now we use the Developer's option to make the certificate, the steps are as follows:
Select the development option
Click the plus sign option above
Select the APNS option (development is, of course, in a sandbox environment, simulate the real situation), and then continue
This appid we say in the next section how to build, now I use an already generated application ID, continue to continue
This way, you will choose to download the Certificatesigningrequest.certsigningrequest file in the Keychain Access link, select and generate
Click Download to get aps_development. cer, and save it to the push file.
Fourth part
Create a new AppID, select Appids on the page, and then click the plus sign in the upper-right corner
The app's name is as long as Apple asks.
Then Bundleid is more important, in the submission of audits and testing (Apple's TestFlight) and pay links need to use, but also just follow the apple requirements to write.
The next step is to choose which services your app needs to use Apple, such as advertising, game center, push, pay, and more.
Finally select the "Submit" option and select "Done" in the next screen so we can set up the AppID step.
Part V: Generating Provisioning Profiles
This configuration profile is divided into two types, one for development and one for publishing to AppStore.
Create a release version of Provisioningprofile with the same process as the development version, click Development and then click the plus sign in the upper right corner
Will go to the interface that chooses which configuration profile to select
We are now testing, so choose "IOS app development" option, in the following distribution publish options, there are two options, "App Store" and "Ad hoc", you can according to the following description
Select the options you want to publish. Click Continue to proceed to the next step.
Select the AppID you created in the previous step and click Continue to proceed to the next
Choose your developer account and continue for the next step
Choose your device at this point (you can only use this signature for debugging on your device if you check your device on this step). about how to add your device number is also very simple, select "Devices" on the left, and then click on the upper right corner of the plus sign, on the subsequent page to add your device's UUID (can be viewed in Xcode) as well as name (you can easily take, you understand the line)
Then register, follow the process to the last step to complete.
Okay, let's go back to the provisioning profile configuration link, and when you've selected your device, click "Continue" to go to the next page.
Enter a file name (it is best to get up and understand what it is to do, of course, can also be casual), click "Generate" to enter the next page, in this page will have a download button to let you download this file,
We download it and put it in the push folder.
Sixth part
Well, the preparatory work is done, now let's start pushing! (ROAR)
First double-click on the "Aps_development. cer" file that we generated, go to keychain access, find our private key (according to the common name that is filled in in the second section from Certificate Authority issuing certificate action)
I fill in the second part is "Silicon", because of a Mac before the installation of No, before, so casually find a picture for everyone to see, with everyone's ingenuity should not be difficult to understand it.
Then right-click on the export, which will pop up the figure shown below.
Save him in the push folder named "Push.p12", and in this step the export will let you enter the password and verify that you can customize a password, such as abc123.
There should now be several files in the Push folder "Aps_development. cer", "PUSH.P12", "Certificatesigningrequest.certsigningrequest" and the configuration profile that just came down.
Next we open the terminal and they build the. pem file
1. Generate the. pcm file from the aps_development. cer file, and the CD to the Push folder
2. push.p12 files to a. pem file
The password entered above is the password you set to export the certificate, that is, abc123. It will also let you enter the password for the. pem file, or use abc123 to prevent confusion.
So we got two more files in the Push folder, Pushchatcert.pem and Pushchatkey.pem.
3. Merge Pushchatcert.pem and Pushchatkey.pem into a PEM file,
There is another CK.PEM file in the Push folder, we have prepared the files we need to use.
The next test, is not very excited ~
In order to test the status of the certificate work, we can use "Telnet gateway.sandbox.push.apple.com 2195" to detect if the display
is a success.
Then we use our generated certificate and private key to set a secure link to the Apple server
Enter the following command at the terminal: OpenSSL s_client-connect gateway.sandbox.push.apple.com:2195-cert pushchatcert.pem-key PushChatKey.pem
Need to enter a password (abc123 we have just set).
Then he will return a series of data, and here I will paste part of it:
CONNECTED (00000003)
Depth=1/c=us/o=entrust, Inc./ou=www.entrust.net/rpa is incorporated by reference/ou= (C) Entrust, Inc./CN=Entrust Certification authority-l1c
Verify error:num=20:unable to get local issuer certificate
Verify return:0
---
Certificate Chain
。。。。。 Omitted
Start time:1416389389
timeout:300 (SEC)
Verify return code:0 (OK)
---
The test is here.
Implementation of iOS development app message push