Android Push Notifications with HCPms

1

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

  1. Goto Google APIs console and create a new project. push blog 1
  2. After creating the project you will find the Project ID. Note down the ID which will be used as sender ID in the project. push hcpms 4
  3. Click on APIs on left hand side and enable Google Cloud Messaging for Androidpush blog 2
  4. Once you are done, click on Credentials and create a server key. Note down the API key. push blog 3

Configuring app in HCPms

  1. Login to HCPms admin cockpit (hcpmsadmin-pxxxxxxxxtrial.dispatcher.hanatrial.ondemand.com). Click on Applications and create a new application with below details. push hcpms 3push hcpms 2push hcpms 1
  2. 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.push 7

Creating Hybrid Kapsel Mobile App

  1. 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.push blog 4push blog 5
  2. Run the app in device.
  3. Click on Register button to register the user with HCPms. You have to enable HTTPS toggle button during registration.
  4. Then click on Register for Push.
  5. push 1

Testing Push Notifications using REST Client

  1. 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.push hcpms 6push hcpms 5

Check the following video to see the push notifications in action !

 

4 thoughts on “Android Push Notifications with HCPms”

  1. Hello Midhun,

    Thank you for informative blog on push notification.I’m facing a error after following all your listed steps above.The error was ,”Cannot read property of “init” was undefined” in this line :” function register() {

    sap.Logon.init(logonSuccessCallback, logonErrorCallback, appId, context);
    }”

    Please guide me..

    Reply
  2. Hi Midhun,

    thanks for this tutorial.
    Just one question do you know if it is possible to use Postman with SAML (Cloud Identity). Thanks and best regards, Daniel

    Reply
  3. I am not able to get notifications when the app is running in background.

    I have included the event listener like:

    sap.Push.checkForNotification(function proccessMissedNotification(notification) {
    alert(“In processMissedNotification”);
    console.log(“In processMissedNotification”);
    console.log(“Received a missed notifcation: ” +JSON.stringify(notification));
    });

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.