2. Copy PushNotification.js from location /plugins/com.phonegap.plugins.PushPlugin/www/ to your /www/ in root folder of project, also add its reference in /www/index.html as:
3. Build the project
cordova build iOS
4. Now next step is to register the device.
For this you will need Apple account to generate certificates and provisions.
You need to make a new App ID and provisioning profile for each app that uses push using iOS Provisioning Portal.
You will also required a server as Push notifications are always sent by a server.
When you create the CSR, a new private key is made that is put into your keychain. You then send the CSR to a certificate authority (in this case that is the iOS Developer Portal), which will generate the SSL certificate for you based on the information in the CSR.
=> Open Keychain Access on your Mac (it is in Applications/Utilities) and choose the menu option Request a Certificate from a Certificate Authority
=> Add email id(apple email id would be recommended) and common name like PushChat and then press continue.
=> Save the certificate with name something like this, Pushchat. certSigningRequest
=> Now go to keys section in keychain you will find there new push private key, export it and save it as pushkey.p12
6. Making the App ID and SSL certificates
=> Login to developer.apple.com and select Certificates, Identifiers and Profiles
=> Select Certtificates in iOS Apps section.
=> Go to App IDs in the sidebar and click the + button and fill the details
=> Press Continue button and click on Submit, now you have added a new App ID.
=> Now you will find new App ID in list. which when expands shows a orange lights that says your App ID can be used for push after configuring the settings.
=> Click on settings that will forward to a window, select there Create Certificate under Apple Push Notification.
=> Add iOS Certificate wizard will show, click on Continue and upload CSR that you have already created. Now click on Generate which will generate a SSL certificate.
=> After click on Continue download the certificate named as aps_development.cer
7. Making a PEM file
=> Open the terminal and use these commands
Go to the folder where all certificate are downloaded.
$ cd ~/desktop/files
Convert the .cer file into a .pem file
$ openssl x509 -in aps&#95;development.cer -inform der -out PushChatCert.pem
Convert the private keys .p12 file into .pem file
$ openssl pkcs12 -nocerts -out PushChatKey.pem -in PushChatKey.p12
Enter Import Password:
MAC verified OK
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
Enter the pass phrase to encrypt the PEM file.
Now, Combine certificate and key into a single pen file
8. Making the PEM file
=> In IOS development center go to Provisioning Profile.
=> Select iOS App Development under What type of provisioning profile do you need? and press Continue.
=> Select App ID that you have created previously, Press Continue.
=> Select devices that you want to include for development.
=> Set the provisioning profile name and press generate.
9. Install the new provisioning profile and .pem file into project
10. Now in js file add the following code within device ready