AboutContact

iOS push notification: how to send messages and get the certificate Part 1/2

In this two parts tutorial for Swift 2.0 you'll learn how to use the push notifications in iOS. You'll see how to properly get from the Apple member center the required certificates. In particular, the certificates that you need to send notifications are: the app ID certificate that defines the requirments and services that your app is using, and the provisioning profile. In the second part of the tutorial, you'll learn how to configure a simple server and a simple app to respectively send and receive push messages.

Create the app id, apns certificate and Provisioning Profiles

Let's start by logging to the Apple member center and click on the App IDs section. Click on the plus button to create a new App ID.

In the App ID description write a representative name for your App. Be sure that explicit App ID is selected and write the package name that you've used for creating your project in swift. It's defined by both the organization identifier and the product name of your app. Something like yourname.yourappname. At the bottom, under App services be sure that Push notifications is checked.

Now let's configure the push certificates. Turn back to App ID, click on the created app, e click on edit to configure the push certificates. On the Push notification section, click on create certificate for the development ssl certificate (if you intend to distribute this app, create the distribution certificate too).

At this point you have to upload the CSR file. You have to generate it through your Mac.

Open the keychain in your Mac, press Keychain Access - Certificate Assistant - Request a certificate from a certificate authority, fill your email address and the common name you want. Be sure that save to disk is checked, and press continue to store your Certificate Signing request. Upload this certificate to the apple portal to generate your apns development/distribution certificate.

Download the generated aps_development/production.cer

Now it's time to generate the Provisioning Profiles. On the Apple member center portal, go to the provisioning profile section, and press the plus button to add a new one. When asked for the type of provisionig profile to generate, choose development (or distribution if you want to distribute it). When asked for the App ID, choose the App ID you previously created. Add a profile name and press on generate. Now download the provisioning profile.

Now you'll have the certificates for using the push notification. Just double click on the mobile provisioning to install it on swift.

In the next tutorial we'll see how to send push notification. We'll see how to configure your app to prepare for push notification. send the token to an external server, and finally how to configure a server to send push notifications

Leave a comment












AboutContactPrivacy