We use GCM to enable push notifications in our apps which is little tricky to implement. HCPms is SAP’s mobile solution on cloud which provides all the enterprise level features to your app. HCPms supports push notifications in all major mobile platforms – iOS, Android and BB. In this tutorial we are going to learn how to implement push notifications in an android app.
This application uses Kapsel SDK (SP08), Cordova 4.2 and Android 5.0.
Registering with Google Cloud Messaging
- Goto Google APIs console and create a new project.
- After creating the project you will find the Project ID. Note down the ID which will be used as sender ID in the project.
- Click on APIs on left hand side and enable Google Cloud Messaging for Android.
- Once you are done, click on Credentials and create a server key. Note down the API key.
Configuring app in HCPms
- Login to HCPms admin cockpit (hcpmsadmin-pxxxxxxxxtrial.dispatcher.hanatrial.ondemand.com). Click on Applications and create a new application with below details.
- Go to HCP cockpit, click on Services then choose SAP HANA Cloud Platform Mobile Services. Click on Configure SAP HANA Cloud Platform Mobile Services. Then choose roles from the left hand side and assign a Notification User. I have used my SCN user as Notification User.
Creating Hybrid Kapsel Mobile App
- Follow this blog to create a Kapsel hybrid mobile application. In the index.html provide the ServerHost as your HCPms host name, port as 443 and GCM senter ID. Username and password could be anything since the app is configured with No Authentication Type.
- Run the app in device.
- Click on Register button to register the user with HCPms. You have to enable HTTPS toggle button during registration.
- Then click on Register for Push.
Testing Push Notifications using REST Client
- For testing the push functionality we could use a REST client to send message to the device. I am using Postman Rest Client in google chrome. Provide Headers and Body and perform a POST request. I am providing credentials as my SCN username (p12345678) and password.
Check the following video to see the push notifications in action !