iOS development--implementation of remote message push

Source: Internet
Author: User

In the process of using the app. Will always receive very much message pushes. Today we are going to implement this feature. First, message push is divided into local message push and remote message push. The most frequent use of remote messages.

But before you push the remote message. There are two prerequisites. You need to buy an Apple developer account, which is 99 knives per year, and there is an iOS real computer (simulator cannot test push). In fact, remote push requires the server, but we do not have the server temporarily, then the background using parse to push.

The implementation process is as follows:

(1) Enter the Apple Developer site: https://developer.apple.com/. Click member Center in the top right corner to sign in. will be entered such as the following interface:



(2) Click certificates,identifiers & Profiles to enter, appear for example the following interface:



(3) Click on Certificates in iOS apps to appear, such as the following interface. To start the configuration:



(4) Turn on Keychain access on your Mac, select Keychain Access-Certificate assistant--Request a certificate from a certification authority.

The user email address and CA e-mail address are all filled in with the developer account you have applied for, often using the name to be arbitrary and then stored to disk.

This will generate a CSR file that needs to be configured on the site.



The resulting file such as the following:



(5) and then come to the developer site just now. Choose certificates-->development (development), assuming you want to publish, you can also select Production, and then click on the right side to see:



(6) Then select the second item on the entry page: Apple Push Notification Service SSL (Sandbox). Click Continue.



(7) Assuming you haven't created an app ID for your app, you'll get an example of the following interface. Create one and you can. then click Continuebutton.



(8) App ID Description name can be arbitrarily taken, I fill mypushdemo.

Fill in the ID of your app in the bundle ID of the explicit app ID, and I'll fill in the Com.chenyufengweb.MyPushDemo.

In the app Services below. Select Push notifications, and click Continuebutton.

Go to the next page and click Submit.


(9) Note. Because we didn't create an app ID at the start. After the steps above, we've just finished the steps to create the app ID. Below we will still create the certificates certificate.

At this point, for example, the following interface, you choose your own to use the app ID can be.


(10) After entering the following interface, select the CSR file that we just accessed from the keychain: then click on Generate.



(11) appear such as the following interface, download our certificate can be, click Done.




(12) So our certificate is generated and configured.



After downloading the file, for example the following:


(13) We also need to generate one thing at this point. Click Certificates-->development, click on the "+" button in the upper right corner and select the first item in the interface that appears (we have previously selected the second Apple Push notifiation). Click Continue.



(14) Ibid. Select the CSR file generated when Keychain access is selected. Click Generate. And then all the way to continue. At this point the interface under certificates



After downloading the CER file, for example, the following:



(15) After the above steps. Our app IDs and certificates are ready to build.

The following is to start configuring Provisioning profile. Click Development in Provisioning profiles (this is development. Suppose you want to announce that you can choose distribution).

.


(16) then click on the "+" button in the upper right corner to add a configuration file.

Select iOS App development. Click Continue to continue.





(17) Select the app ID we generated just now to:




(18) Then select our certificate to do so.

Click Continue to continue.



(19) Select the device we need to test in the following interface, all selected. Continue continues.



(20) Enter the profile Name. You can do whatever you like. Click Generate to go.



(21) Then download the profile file.



After downloading the file, for example the following:




(22) Pass the above steps. Our configuration on the Apple developer site is complete. Now that we have downloaded 3 files, just double-click the three files to install them.







(23) Turn on Keychain Access again at this time. The certificate that we just generated and installed will appear in certificates.





(24) Right click to export this certificate.





You can enter password and verification, but we use parse as the background to push, parse does not need to verify, we directly click "OK" can.


Finally enter our computer password can.



Finally, the. p12 file is generated on the desktop.



(25) Below we start using parse for push. Website: http://www.parse.com/.

Register an account, then create a new app,




(26) Click on the left side panel app Setting-->push. Upload the. p12 file that you just generated in the Apple Push certificates on the right.



After the upload is successful, for example:



(27) All configurations are now complete. Start to write the code.

We steal a lazy, directly from the parse download demo use. I also uploaded to GitHub. You can use it directly: Https://github.com/chenyufeng1991/iOS-ParsePushDemo.

Select Download.




(28) Then it will appear such as the following interface, select Blank Project to download an empty file. Unzip open to be able to use.




(29) Open the project, enter the PARSESTARTERPROJECTAPPDELEGATE.M file, and uncheck the following line of code:

[Parse setapplicationid:@ "your_application_id" clientkey:@ "Your_client_key"];

Then come to parse again, and find the application ID and client key from app Settings-->security & Keys and fill it in with the code above.



Now this line of code becomes:

[Parse setapplicationid:@ "2mrclbjlep3pf4s8tnof14jcy2qjh4tvekzta41k" clientkey:@ " N0onfuozbzrddxkztkbb9aolyli9uiwzilzeeo5s "];


(31) To change the app ID at the same time, I just set the Com.chenyufengweb.MyPushDemo. Just change it in the bundle identifier of the Info.plist file.



(32) then go to targets-->build stetings and enter code sign search on the right. Set the provisioning profile below to the name we entered on the developer site and set the code Signing identity to its developer account.


(33) After the above complex steps. You will be able to execute the program on the real machine. When the program executes, I push a message on the parse. Enter push. Then click on the Send a push in the upper right corner.

.


.


(34) A message is then pushed on the parse.

Click Send To do it.



(35) about a few seconds later. The client will receive a push message. Click the push message to access the app. At this point, the entire remote message push is complete.



Summary: The remote push configuration process is cumbersome. Suppose everyone has the time to be able to APNs and sign. Provisioning profile, certificate and other concepts to understand, will be more handy.



GitHub Home:https://github.com/chenyufeng1991 . Welcome to visit us!


iOS development--implementation of remote message push

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.