Remote push push for iOS development

Source: Internet
Author: User

Remote push NotificationsWhat is remote push notification

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

Why remote push notifications are required
  • limitations of traditional data acquisition as long as the user closes the app, they can't communicate with the app 's server and get the latest data content from the server .
  • remote push notifications can solve these problems no matter whether the user opens or closes the app, you can receive remote notification of the server push as long as the internet is connected
tips for using remote push notifications
  • all Apple devices, in a networked state, will have long connections with Apple's servers What is a long connection as long as the network is connected, it has been established.
  • effects of long connections Time Calibration System Upgrade Find My iPhone .. ...
  • Benefits of long connections Fast data transfer speed Keep your data up to date
Push principle

Provider is our company's server, through Apple's APNs server to find our device, to our device on the client app push message. The APNs server is how to find the application on our devices and devices, the answer is Devicetoken,devicetoken need to configure a push certificate to get, push the certificate need to know our app ID (app Bundleid, Application unique identification) and UDID (device unique identification), as well as the udid of their own server, we first to hit a push certificate, login to the Developer center, click the certificate module

Click the certificate for your iOS apps

into such an interface

Click App IDs, then click the plus sign in the upper right corner

The arrow refers to the app ID description, we assume that we wrote a very good app, Excitedapp, and then we fill in the app ID, note that the app ID here is fixed, cannot have an asterisk

Next we add the services needed by the app, then click Continue

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

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

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

Click the Continue we see

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

Top two random write, last select Save to disk

When we're done, we're ready to add the CSR file.

Finish adding, select Build

The certificate is ready, download it

It's ready!

Let's take it with us. The certificate is also assigned, 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 change the bundle ID here's a real Machine debug certificate.

Real machine debugging things here not to be tired of, so many things, we can finally get Devicetoken

Register for Push in APPDELEGATE.M

1-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {2     3Uiusernotificationtype types = Uiusernotificationtypebadge | Uiusernotificationtypesound |Uiusernotificationtypealert;4     5Uiusernotificationsettings * setting =[uiusernotificationsettings settingsfortypes:types categories:nil];6 [[UIApplication sharedapplication] registerusernotificationsettings:setting];7 8     returnYES;9}
1-(void) Application: (UIApplication *) application Didregisterforremotenotificationswithdevicetoken: (NSData *) Devicetoken2 {3NSLog (@"%@", Devicetoken);4}

devicetoken processing process

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

Add our push certificates to the project directory

And then you can get a push on your phone.

Remote push push for iOS development

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.