IOS Remote push push development tutorial _ios

Source: Internet
Author: User

Remote Push notification

What is a remote push notification

As the name implies, is the notification from the remote server to the client (requires networking) remote Push service, also known as APNs (Apple push Notification services)

Why remote push notifications are required

The limitations of traditional access to data as long as users shut down the app, they can't communicate with the app server and get the latest data from the server.

Remote push notification can solve the above problem regardless of whether the user turns on or off the app, as long as the network, can receive the server Push remote notification

Tips for using remote push notifications

    • All Apple devices, in the networked state, will be connected to the Apple server long connection what is a long connection as long as the network, it has been established
    • Long connection action Time calibration system upgrade Find My iphone. ...
    • Benefits of long connections data transmission speed Fast date keep up to date

Push principle

Provider is our company's server, after Apple's APNs server to find our equipment, to our devices on the client application push message. The APNs server is how to find the application of our equipment and equipment, the answer is that devicetoken,devicetoken need to configure the push certificate can be obtained, push certificate need to know our app ID (Application of Bundleid, Apply unique identification) and UDID (device unique identification), as well as its own server Udid, we first to play a push certificate, login to the Developer center, click on the certificate module

Click on the iOS apps certificate

into such an interface

Click App IDs and then point to the plus sign in the upper right corner

The arrow refers to the application ID description, and we assume that a very good application is written, Excitedapp, and then we fill in the app ID and notice that the app ID is fixed and cannot have an asterisk.

Next we add the services that are needed for the app and click Continue

Always click Next, Finish, find our Excitedapp in the app IDs list, we see

Find the push service is a yellow warning, click Edit to find the push module, we need to configure the push certificate, click the red arrow Point

We need a CSR file, a CSR is a signature request file, which means that our Mac has the right to debug push, click Continue

Click on the continue we see

Then we open the keychain on the Mac and request the certificate from the certification authority

The first two write casually, finally choose to save to disk

When we're done, we can then add the CSR file.

Finish adding, select Build

The certificate is ready, download it down

It's good!

Let's take it with us the certificate of the release is also given, the steps are the same

Open the certificate we just downloaded and add it to the keychain

Finally, we can start the whole project, and we're going to cry.

Don't forget to modify the bundle ID here's a certificate for real-machine debugging.

Real machine debugging things here are not tired, so many things, we can finally get Devicetoken

Registering a push in APPDELEGATE.M

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {
  
  Uiusernotificationtype types = Uiusernotificationtypebadge                              | Uiusernotificationtypesound | Uiusernotificationtypealert;
  
  uiusernotificationsettings * setting = [uiusernotificationsettings settingsfortypes:types categories:nil];
  [[UIApplication sharedapplication] registerusernotificationsettings:setting];
 
  Return YES
 }

 -(void) Application: (UIApplication *) application Didregisterforremotenotificationswithdevicetoken: (NSData *) Devicetoken
 {
  NSLog (@ "%@", Devicetoken);
 }

devicetoken Processing Process

Next we use Pushmebaby to test our push: https://github.com/stefanhafeneger/PushMeBaby/

Add our push certificate to the project directory

Then you can receive a push on your phone.

This article has been organized into the "iOS push Tutorial", welcome to learn to read.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

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.