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.
Image6 6 4621425

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) (SP14-), Firebase Cloud Messaging (SP15+), Apple Push Notification Service (APNS) and Windows Push Notification Services (WNS) overview. 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 of a URL used in a REST call.

https://localhost:8080/restnotification/registration/application_registration_id https://localhost:8080/restnotification/application/com.kapsel.gs/user/daniel_v https://localhost:8080/restnotification/application/com.kapsel.gs

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)" }

If the SAP Cloud Platform mobile service is being used, the Push Desk can also be used to send a notification. Note a filter must be applied to see the registration list.

Note that push requires open ports that may be blocked on some corporate networks or routers. GCM 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:SAPMobileSDK3KapselSDKdocsapisap.Push.html or Push Notification 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.
Image1 5 3671882

Note, the Push plugin on Android requires the below two checked components from the SDK Manager.

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

  • Create a server key by creating a new project in the Firebase console. After the project is created, open it and then select Project Settings Image16 3 8295337, then click on the tab CLOUD MESSAGING to display the sender ID and Server API Key.

    Note, either the Server key or Legacy Server key can be used.For more details on the sender ID and Server API key see Credentials.See also Firebase Cloud Messaging and GCM and FCM Frequently Asked Questions.
  • Fill in the Push settings for the application.
    Image2 2 5962006
  • The following instructions set the user name and password that can be used to send notifications when using an SMP server.
    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.
    Image14 2 3709629
    Restart the SMP 3.0 server.
  • The following instructions specify the user that can send notifications with the SAP Cloud Platform Mobile Services server.
    Add your user to this role in the SAP Cloud Platform Cockpit.
    Choose Services > Development & Operations > Configure Development & Operations > Roles > Notification User > Assign.
  • Delete the app KapselGSDemo from the device.
  • Remove the AppUpdate plugin and add push plugin.
    cordova plugin remove kapsel-plugin-appupdate cordova plugin add kapsel-plugin-push --searchpath %KAPSEL_HOME%/plugins
  • Replace wwwindex.html with the following contents.

    Push Sample

  • If you are using SP15 or above, follow the instructions at https://support.google.com/firebase/answer/7015592#android to download the google-services.json and copy it to C:Kapsel_ProjectsKapselGSDemo.
    Image17 1 3973783
  • Prepare, build and deploy the project.
    cordova run android
  • Note that in the logonSuccessCallback the registerForPush method is called which registers the device to receive push messages the first time it is called and on subsequent calls initializes the push functionality in the app.
  • Send a REST request to the SMP server to send a notification to the Kapsel app. Note the example below is using Postman and the provided collection from the section Accessing the Application using the REST API. Remember to use the credential smpPushUser and smpPushPassword under the Authorization tab after selecting Basic Auth.For further details see Notification Data Sent Using Push API and GCM Push Notification Payload Handling.
    Image10 3 6591500 {"alert":"New Vacation Approval Request", "data":"For (i82XXXX) request (7)" } https://localhost:8080/restnotification/registration/59a72605-2a64-4778-953d-c215a7d565eb {"alert":"New Vacation Approval Request", "data":"For (i82XXXX) request (7)" } https://localhost:8080/restnotification/application/com.kapsel.gs/user/i82XXXX {"alert":"New Vacation Approval Request", "data":"For (i82XXXX) request (7)" }
  • Now press the back button to exit the app and send the notification again. The notification should appear on the device or simulator and clicking on it will open the app.

    The details of the selected notification will be processed in the processNotification method.
  • A new feature in SP15 is the ability for the push plugin to report to the SAP Cloud platform server that the notification is received and if the notification was opened or consumed by the app.
    Image18 1 9494488

    In the above graph, 1 notification has been sent but not received and one notification has been received but not consumed. Once the device or emulator receives the notification, the chart would change to have 0 notifications in a sent state and 2 notifications in a received state.Note, it is up to the application to call the setPushFeedbackStatus API when the app processes the notification and pass in ‘consumed’ as a parameter.
    The Kapsel push plugin automatically notifies the server when it receives the notification on the device.
    The application should add a call to setPushFeedbackStatus in the processNotification method if they wish to notify the server that the message was processed by the user.
  • 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().
    Image7 3 6519815
  • 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, the sound played when a notification arrives can be selected. Settings > Sound & notification> Default notification ringtone.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-20130917sdkplatformsandroid-19data
    awfallbackring.ogg to storagesdcardNotifications. Restart the emulator. Fallbackring should now be accessible in the settings.
  • You may also be interested in the some of the other push plugins available such as the phonegap-plugin-push.
  • The following posts may also be of interest.
    Keeping Google Cloud Messaging For Android Working Reliably
    How to call the REST Notification API of SMP 3 from ABAP in an Username based scenario
    Delay in receiving messages of 15 minutes or 28 minutes


  • On some Android devices, there is an error while registering for notification.
    java.lang.UnsupportedOperationException: Device does not have package com.google.android.gsf

    This may occur if the Google Play Services are missing. In order to receive push notifications, 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.

  • 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.The message Invalid Notification target id indicates that device did not successfully register for push. This can be investigated further via the below select command.
    SELECT * from SMP-NOTIFICATION-TARGET where TARGETID = '' Verify that the - row exists, - TARGETID value is the connection ID, - CONFIGID value is the application ID - DEVICENOTIFICATIONKEY1 is the device ID from the gateway/ device ID from APNS or GCM - NOTIFICATIONTYPE must not be null, 0 for APNS, 1 for GCM, 2 for Blackberry, 4 for WNS and 5 for MPNS
  • 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.

Back to Getting Started With Kapsel

New NetWeaver Information at SAP.com

Very Helpfull



User Rating: Be the first one !