In this tutorial , i will tell your about APNS (Apple Push Notifications Service). APNS is used to send notifications to iOS devices like iPhone , iPad .
Apple Push Notifications includes :
3. Text Alets
Requirements for APNS :
1. You need a paid iOS developer account.
2. iOS device (iPhone or iPad) (Push notifications can`t be tested on simulator).
Step 1 :
Create a CSR certificate
1. Open Keychain access .
2. On the top toolbar , go to Keychain access >> Certificate assistant >> Request a certificate from the certificate authority .
3. Enter your email address, common name when prompt.
4. Click on save to disk and choose the location where you want to save the csr certificate.
Step 2 :
Enable Push notifications and configure them for your application.
1. Login to Apple developers account.
2. Go to App id`s and create a new app id. You have to fill in the name of your application and the bundle identifier for your application. (Bundle identifier should be same as your project bundle identifier).
3. After creating you app id , you need to edit it and configure your push notifications .
4 . Create push notifications for development and add the csr certificate which you have created earlier .
5. Your push notification certificate for development has been created , Download the certificate .
Step 3 :
Create p12 file
1. Open the downloaded certificate , and expand it. You will see a private key .
2. Select both certificate and private key and export them into .p12 file.
3. Enter the phase password, and then yours mac password.
4. p12 file is now been created.
Step 4 :
Convert p12 into pem file.
We have to convert p12 file into pem file because we have to link PEM file with server , so that we can receive push notifications from server.
1. Open terminal.
2. Write cd (Location where you have stored the p12 file ). e.g.. cd desktop
3. Write a command in terminal which will convert p12 file into PEM file :
(where apns-dev-cert.p12 is my p12 file which will get converted into apns-dev-cert.pem )
4. Your PEM file is now been created.
Step 5 :
Configure AppDelegate of your project.
You have to configure AppDelegate , to enable push notifications .
1. Go to appDelegate.m in your project.
2. Add the following code to enable push notifications to your project and get a device token :
Use deviceTokenString to send push notifications to your device.
Step 6 :
You can check online weather your Push notifications are working fine or not by visiting CHECK APNS ONLINE
Thats all about Apple Push Notification Service .
Thank you :)