This is the continuation of the blog started here. You only need this part if you are going to develop and test push notification for iOS devices. If you are not interested in this part you can simply skip it an go to the last part of this article.I’ve decided to write this blog to show clearly how you can enable your mobile devices, iOS or Android, to leverage the capabilities of Push Notifications provided by the HCPms.
This blog has been split in 3 parts:
|How to use Push Notifications with iOS and Android Hybrid applications – part 1||Step 1 – Enable push notifications for Android|
|This part||Step 2 – Enable push notifications for iOS|
|How to use Push Notifications with iOS and Android Hybrid applications – part 3||Steps 3 -> 6 – Create an app on HCPms, then another in SAP Web IDE, deploy the app to mobile services and test the app with some push notifications|
Step 2 – Enable push notifications for iOS
For iOS is a little bit more complicated because instead of having just a server API key and a sender ID, you need to request a certificate and upload it to HCPms.
NOTE: For this step a MAC is required, you CANNOT perform these steps on a Windows machine.
1 – Open Keychain
2 – Click on Keychain Access –> Certificate Assistant –> Request a Certificate From a Certificate Authority…
3 – Enter your email, select Saved to disk and click on Continue
4 – The certificate (CertificateSigningRequest.certSigningRequest) will be saved somewhere on your disk
5 – Click on Done
6 – Go to Apple Developer portal https://developer.apple.com/ and click on Account
7 – Enter your credentials
8 – Select your team if needed
9 – Click on Certificates, Identifiers & Profiles
10 – Click on on Identifiers –> App Ids
11 – Click on the “+” sign in order to create a new App ID
12 – Enter a name for your application (i.e. “Acme Push Notifications”) and choose the right App ID Prefix.
13 – Normally you can use the App ID Prefix related to your Team ID. You can get it by looking in the Membership Information in Xcode
14 – In the App Services section, enable Push Notifications and click on Continue
15 – Push Notifications are now Configurable. Just click on Register
16 – Click on Done
17 – Search for the application ID that you have just created, select it and click on Edit
18 – Select Push Notifications and choose Create Certificate in the Development SSL section. We are just using our application for testing.
19 – A new window opens. Click on Continue
20 – Click on Choose File to upload your CSR certificate we have generated some steps ago.
21 – Select the certificate and click on Choose
22 – Click on Continue
23 – Your certificate is ready. Click on Download to download it somewhere on your machine
24 – The name of the certificate will be something like aps_development.cer.
25 – Click on Done
26 – Go in the folder where you downloaded the aps_development.cer and double click on it. The certificate is automatically installed in your Keychain. You can check that it’s installed correctly by going in the Keychain tool, selecting the Login Keychain and looking in the Category section under My Certificates.
27 – The certificate is installed correctly! Now we need to export it in a different format so that it can be used to create a provisioning certificate. Right click on it in the Keychain Tool and choose to Export it somewhere on your machine
28 – Save it as a .p12 format
29 – Enter a password to encrypt the certificate
30 – The new certificate is stored on your machine
31 – On the Apple Developer portal, go to the Provisioning Profiles –> All section
32 – Click on the “+” sign to create a new Provisioning Profile
33 – Select iOS App Development and click on Continue
34 – Locate your app in the combo box and click on Continue
35 – Select the certificate that you want to include in this provisioning profile. In this case I’m choosing just the one related to my name
36 – Select the devices on which the application has to run and click on Continue. You can select several devices
37 – Keep the proposed name and click on Continue
38 – Download the provisoning profile on your machine
39 – Click on Done
40 – Double click on the provisioning profile certificate you just downloaded. It will be automatically installed in XCode
41 – Open Xcode and go in Xcode –> Preferences
42 – Click on View Details
43 – Under the iOS Development session you should be able to see your certificate
Let’s continue now with the last part of this article where you will learn how to use push notification with a hybrid application on your mobile devices.