Monday, 23 June 2014

All about Apple Push Notifications

What are Push Notifications?

Push notifications are great for keeping users informed with timely and relevant content, whether your app is running in the background or inactive. Notifications can display a message, play a distinctive sound, or update a badge on your app icon.

What you need for Push Notifications?

To add push notifications to your app, you need:
a. An iPhone or iPad Push notifications do not work in the simulator, so you will need to test on the device.
b. An iOS Developer Program membershipYou need to make a new App ID and provisioning profile for each app that uses push, as well as an SSL certificate for the server. You do this at the iOS Provisioning Portal.
c. Server : Push notifications are always sent by a server

We will do deep into creating Certificates, App Id, Provisioning Profiles etc :

Certificates : 

First open “keychain Access” —>certificate assistant—>Request a certificate from a certificate authority menu item 


Give email address and select the 'Saved to disk' radio button
Press continue and save the certificate request to your disk and press the done button.  You will need this file at two points later in the process.

Till now we are done with the Keychain application, We will get back to this after some process.
Now go to the Apple Developer Portal  -> Select Certificates.

Under "Development", if it is empty like below, Click Request Certificate,click on “+” to create —>select the “IOS App Development” and click “continue”
and upload the certificate which we saved to disk from keychain access.

                                     



Click Submit and you will find this window. Click Download and save it in a folder.




You will then need to install this into the keychain access program by double clicking the .cer file after it is saved to your system.  This will cause the keychain access program to install the certificate and you should see something similar to the following in the keychain access application


I have expanded the top level item to show the private key that is part of the certificate.  You will need that private key to generate a certificate file for the C# application to use.
private key—>right click—>Export and Save .p12file  (“developer_private_key.p12”)—>name i given and give password as u want and keep it some where  .the password will be used for further process.


Now we are done with the Certificates part. We will move to App ID.



App ID : 

Click on Apple id—> “+”



Give name and Bundle id (id same as project bundle id)—>select push notifications—>continue


App id is displayed in the page, with the application services 

Click Edit and you will be navigated to Configure App id page.


Check the 'Enable for Apple Push Notification service' check box, and the two 'Configure' buttons will be enabled.  Press the 'Configure' button for the 'Development Push SSL Certificate'.  You will then be presented with a series of dialogs to guide you through creating the SSL certificate.


click continue.If this is not available create a certificate as we created first time i.e .CSR
then choose file .csr from saved path and click on Generate




Click Download and Done 
Save the certificate('aps_developer_identity.cer')  we will be using this for creating .p12 in further steps