Skip to Content
Author's profile photo Daniel Van Leeuwen

Getting Started with Kapsel – Part 4 — Push (SP09+)



If you are using SP13 or newer please see
Push messages provide a way to inform or remind a user that an action should be taken by delivering a short message that appears as a notification on the device.


When clicked on, the app that is associated with the message is opened.

The Kapsel push plugin provides an abstraction layer over the Google Cloud Messaging for Android (GCM) and Apple Push Notification Service (APNS).  A notification can be sent to a device via a REST call to a specific registration id, a user id that may have registered on multiple devices, or to all users of an application as shown in the following examples.


The REST call should also include a payload for the message such as the following.

{"alert":"New Vacation Approval Request", "data":"For (i826565) request (7)" }

Note that both GCM and APNS require open ports that may be blocked on some corporate networks or routers.  GCM on older devices uses ports between 5228 and 5230 on older Android devices as per Google Cloud Messaging not working on 4.1.2 devices on a corporate network.  APNS uses the ports described here.

For additional details see C:\SAP\MobileSDK3\KapselSDK\docs\api\sap.Push.html or Using the Push Plugin.

The following steps will demonstrate this plugin using Google Cloud Messaging.  Note, it requires either an Android 4.2.2 or higher device with Google Play Store installed (Setting Up Google Play Services) or an Android emulator that targets the Google API’s.

Note, the Push plugin requires the following Android SDK library to be downloaded.  This will resolve the dependency in the build.gradle file for play-services-gcm.

The process for iOS and Windows is covered by others.  Here are a few posts to check out.
Apple Push Notification Services in iOS 6
[Kapsel] How to use the Push plugin on iOS
[Kapsel] How to use the Push plugin on Windows

  • Follow the instructions at Try Cloud Messaging for Android and click on the button GET A CONFIGURATION FILE in step 2, when asked, click on ENABLE GOOGLE CLOUD MESSAGING and then record the sender ID and Server API Key.
  • Follow the steps shown in Configuring a Kapsel App in the Management Cockpitto create an Application with the application id of

    This app does not use an OData endpoint so the endpoint can be set to a dummy URL such as

    and add the Basic SSO mechanism and the default security provider.

  • Fill in the Push settings for the application.
  • Edit the Notification security provider and add a System Login (Admin Only) authentication provider.  Set the user name and password to a value like smpPushUser and smpPushPwd and the role Notification User.  Note this user name and password will need to be entered later when we send a notification to the device using the Advanced REST client.
    image5.PNGRestart the SMP 3.0 server.
  • Create the project.
    cordova create C:\Kapsel_Projects\PushDemo com.mycompany.push PushDemo
    cd PushDemo
    cordova platform add android
  • Add push plugin.
    cordova plugin add kapsel-plugin-push --searchpath %KAPSEL_HOME%/plugins
  • Replace www\index.html with index.html.
    Update index.html and enter the serverHost(line 10) and sender ID (line 77).  Note the sender ID is an optional setting as of SP10.
  • Prepare, build and deploy the project.
    cordova run android
  • Click on the Register For Push button
    image8.PNGNote that when reopening the app, the Register For Push button must be pressed again or in a non-sample app, it should be called in the logonSuccessCallback method which would be called each time the application starts.
  • Send a REST request to the SMP server to send a notification to a Kapsel app.  For further details see Notification Data Sent Using Push API.image10.PNG

    An example using Postman.

    When prompted for a User Name and Password enter smpPushUser and smpPushPwd.  The following are some further examples.
    {"alert":"New Vacation Approval Request", "data":"For (i826565) request (7)" }


    {"alert":"New Vacation Approval Request", "data":"For (i826565) request (7)" }


    {"alert":"New Vacation Approval Request", "data":"For (i826565) request (7)" }

    If the status is 403, this indicates a permission problem.  Double check that that the correct user id and password for the Notification security profile were correctly entered.  Also double check that the correct role name of Notification User was assigned to the Roles of the authentication provider for the Notification security profile.

    If the status is 404, this may indicate that the app did not successfully register for notifications.  Try pressing the Register for Push button again and verify that the Successfully registered alert displays.

    If the status is 200, this may indicate that the app has not registered and received a registration id from Google or perhaps that there is some issue reaching the Google GCM service.  Double check that the sender ID was added to the index.html.

  • The notification will be processed by the app if it is running in the foreground.
  • Now press the back button to exit the app and send the notification again from the Advanced Rest Client.  The notification should appear on the device or simulator and clicking on it will open the app.  Notice that a custom icon was used by replacing the file


    If the app is not in the foreground when a notification arrives, the details of the notification can be accessed by calling sap.Push.checkForNotification(processMissedNotification).

    Note the notification shown will be for the notification that was selected from the notification bar.

  • A logcat filter using the log tag value of PUSH will filter out the messages sent from the Kapsel push plugin.  Note, this filter will not show the messages displayed using console.log().
  • Push notifications can be disabled on Android and iOS.
    On iOS open Settings > Notifications > PushDemo
    On Android open Settings > Apps > PushDemo > Uncheck Show Notifications
  • On Android, there are separate volume controls.  If you do not here a notification sound, check the volume level for Notifications. Settings > Sound > Volumes > Notifications.
  • On Android, the sound played when a notification arrives can be selected.  Settings > Sound > Default notification.On an Android emulator, the sound file first needs to be copied onto the device.  Open the DDMS perspective in eclipse, select the File Explorer and copy C:\adt-bundle-windows-x86_64-20130917\sdk\platforms\android-19\data\res\raw\fallbackring.ogg to storage\sdcard\Notifications.  Restart the emulator.  Fallbackring should now be accessible in the settings.
  • On some Android devices there is an error while registering for notification.
    java.lang.UnsupportedOperationException: Device does not have package

    This may occur if the Google Play Services are missing.  In order to receive push notifications on those devices when using SP10 of the SDK or higher, follow the below instructions.
    Open the Android SDK Manager click on the Obsolete checkbox and download Extras >Google Cloud Messaging for Android Library (Obsolete) Copy the below jar into the libs folder of the PushDemo project.


Note, there is an open source push plugin that is described at Cordova Push Notifications Plugin.

The following post describes some items to keep in mind once your push enable app is ready for release.  Keeping Google Cloud Messaging For Android Working Reliably.
Note, there is a feature of the SMP and HCPms server called Push Hub.  A description of this is available at SAP HANA Cloud Platform mobile services – Feature Release

Back to Getting Started With Kapsel

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Manuel Ramirez
      Manuel Ramirez

      Hi Daniel.

      I have been using this successfully before, but now I need something a bit different.

      The backend I'm using now is not sending push notifications, so we are just trying to make a local notification every time the oData source is refreshed and send a new item.

      There is any way to make this work only as local notification, or simulate a local push to make the plugin get it as a push and show a notification?


      Author's profile photo Daniel Van Leeuwen
      Daniel Van Leeuwen
      Blog Post Author

      I don't think I am following.  Can you explain this in a bit more detail perhaps with a concrete example.  It might also make sense to post this as a new discussion so others can more easily find and hopefully answer.  In case it helps there is a section that covers an open source push plugin at  Getting Started with Kapsel - Appendix H -- Non Kapsel Plugins (SP09+)


      Dan van Leeuwen

      Author's profile photo Manuel Ramirez
      Manuel Ramirez

      Hi Daniel.

      I will make a separate post.


      Author's profile photo Former Member
      Former Member

      Hi Daniel,

      I would just like to ask regarding when the next version would come out (Probably SP10?).

      And as a followup, does SP09 fully support Android Lollipop? I noticed crashes when deploying on Lollipop, specifically with regards to SMP Kapsel Push and something to do with the GET_TASKS permission, as this is already deprecated as of Lollipop. I would just like to ask for your inputs on this one?

      And finally, what is the license being used by the SMP Kapsel SDK (GNU, OpenPublic, Apache etc etc)? And how would it affect the idea of modifying a Kapsel plugin (.jar)?

      Hoping for your response.



      Author's profile photo Daniel Van Leeuwen
      Daniel Van Leeuwen
      Blog Post Author

      Are you seeing the crashes with SP09?  Note that the plugin was changed in SP09 to use a newer library so if you are using SP08 or later, I would suggest trying the latest SP09 version.  If upgrading does not resolve, can you provide a few more details on how to reproduce the problem and perhaps some lines from the Android LogCat of the error.

      Yes SP09 of the Kapsel SDK supports Android Lollipop.

      I believe the SP10 patch is nearing the end of its development cycle.  I don't have an exact date of when it will be released but it should be coming soon.

      I don't believe the source code to the Kapsel plugins is provided so it may not be very easy to make changes. 

      What sort of changes were you hoping to make?

      Note there is an open source push plugin.  That might be worth looking into.  phonegap/phonegap-plugin-push · GitHub


      Dan van Leeuwen

      Author's profile photo Former Member
      Former Member

      Hi Daniel,

      I've been searching for a way to make the app sync in background (with the odata plugin), after receiving a push notification when closed or in background.

      Checking the API referene of the push plugin, I couldn't find a way to define a callback for when the app receives a push when closed, so I guess I'll have to work with this push plugin: phonegap/phonegap-plugin-push · GitHub

      And then use this plugin to execute javascript code in the background: Build your own Background Service · Red-Folder/bgs-core Wiki · GitHub

      But would it be possible to call the OData plugin to sync the offline store within the bgs-core plugin? Or I really need to have an app running in the foreground to access it?


      Kenyon Tu

      Author's profile photo Daniel Van Leeuwen
      Daniel Van Leeuwen
      Blog Post Author

      In SP10, the iOS Kapsel Push plugin has some support for background notifications.  I have not myself used these but it is briefly mentioned in the link below.  Search for Remote Push Notifications.

      Push Plugin Overview - Developer - SAP Library

      I assume you would need your solution to work on both iOS and Android so not sure this is going to help and also not sure how this solution works in practice with a Hybrid app. 

      It may make sense to create a separate post for this.  I am curious to see how you make out.


      Dan van Leeuwen

      Author's profile photo Diether De Coninck
      Diether De Coninck


      I added the a cert to my SMP server following the instructions above. Now when I use chrome to access my admin console I get 'Server has a weak ephemeral Diffie-Hellman public key'. How can I fix this?

      Author's profile photo Jitendra Kansal
      Jitendra Kansal

      Diether De Coninck

      There is a workaround available for this Weak ephemeral Diffie-Hellman public key | SCN

      Author's profile photo Daniel Van Leeuwen
      Daniel Van Leeuwen
      Blog Post Author

      Updated for SP10 of the SDK.

      Author's profile photo Pavel Lazhbanau
      Pavel Lazhbanau

      Hi all,

      I've implemented all steps from this tatorial, but if I press "Register For Push" button. the message "Error while registering, Register for notification failed to reach gcm server".

                  function registerForPush() {

                      var nTypes = sap.Push.notificationType.SOUNDS | sap.Push.notificationType.ALERT;

                      sap.Push.registerForNotificationTypes(nTypes, regSuccess, regFailure, processNotification, '315667086530' /* optional GCM Sender ID */);


      My SMP configuration is in atached image.

      Should I put google-services.json file to my project?

      What can be wrong?


      Author's profile photo Pavel Lazhbanau
      Pavel Lazhbanau

      Issue was resolved. I run app from corporate network



      Author's profile photo Former Member
      Former Member

      Hi Daniel,

      We tried running the push notification demo application, and it is working fine. However, we were wondering if previous notifications can be cleared off, upon receiving the new notification.

      Also, is there a unique id that we can associate with each notification? Say, we have two different push notifications, and we want to clear off previous instances of one particular push notification. Is that configuration possible?