Skip to Content
Author's profile photo Steve Lutarewych

How to use SAP HCP, mobile service for SAP Fiori – part 4

This blog post is continuation of a 4-part series on How to use SAP HCP, mobile service for SAP Fiori.

Part 4: Feature Management – Adding Push Notifications

In this fourth part, we’ll take the Product Listing app that we created and add support for Push Notifications.  You’ll learn how to…

  1. Update the app with some Javascript code to register for push notifications using WebIDE
  2. Register your app with Google to get the required Push IDs
  3. Update the Fiori Mobile App Settings with your Push IDs, rebuild the app, and update your device
  4. Send a Push Notification using the Advanced REST Client plug-in for Google Chrome

Step-by-step guide:

The first step is to update our Fiori App with the appropriate Javascript to register the app for Push Notifications. We will add a button that the user can click to enable Push Notifications.

1. Open the Product Listing app in WebIDE


2. Expand the view folder then right-click on the Master.view.xml file and select Open in Layout Editor. NOTE: The Layout Editor only works in Chrome right now. If the Layout Editor is not an option, select Code Editor and edit the xml directly.


3. From the Controls Palette, Under Action select the Button Control then drag it to the toolbar on the bottom of the Master view.


4. In the properties section, change the text for button from “Button” to “Register”


5. Expand the Events section, then in the Press Field click the Dropdown menu and select New Function.


6. Enter “pushRegistration” for the name of the new function and click “ok.”


7. Click on the small icon to the right of the Press Field to go to the newly created function in the Master.controller.js.



8. Copy and paste the following code inside your new pushRegistration Function

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

sap.Push.registerForNotificationTypes(nTypes , this.regSuccess , this.regFailure , this.processNotification);


This function will call the asynchronous Push Registration method, which is looking for three callback functions to handle the results. We will create three new functions called regSuccess, regFailure, and processNotification. Copy and paste the following code right above the new pushRegistration function that we just added

                regSuccess: function(result) {



                    “Registered For Push Notifications”, {

                    icon: sap.m.MessageBox.Icon.INFORMATION,

                    title: “Success”,

                    actions: [sap.m.MessageBox.Action.OK]



          regFailure: function(errorInfo) {



                    JSON.stringify(errorInfo), {

                          icon: sap.m.MessageBox.Icon.INFORMATION,

                          title: “Push Registration Failed”,

                          actions: [sap.m.MessageBox.Action.OK]




          processNotification: function(notification) {

              if (sap.Push.isPlatformIOS()) {

                    var notif_alert = JSON.parse(notification).payload.aps.alert;

                    var notif_sound = JSON.parse(notification).payload.aps.sound;

                    var notif_badge = JSON.parse(notification).payload.aps.badge;

                    var notif_data = JSON.parse(notification);

              } else {

                    var notif_alert = notification.payload.alert;

                    var notif_sound = notification.payload.sound;

                    var notif_badge = notification.payload.badge;

                    var notif_data =;




                    notif_data, {

                          icon: sap.m.MessageBox.Icon.INFORMATION,

                          title: notif_alert,

                          actions: [sap.m.MessageBox.Action.OK]





After pasting, if there are any red spaces you will want to remove them. The, right click in the file and Select “Beautify” to clean up the display of your code.


9. Save your changes and deploy your updated project.





Now that we have added some code to register the app for Push Notifications, we need to register our app with Google so we can get the required IDs for sending Push Notifications.

1. Go to and login with your Google ID (if you don’t have one you will need to register first).

2. To complete the form you will need the App ID of your Fiori App. Go back to WebIDE and open your manifest.json file in the Code Editor.Picture1.png

3. Copy your App ID from WebIDE (from the manifest.json file) and paste it in the Android Package Name field.


4. Enter an App Name and Select your appropriate country then click “Choose and Configure Services.”


5. Select Cloud Messaging.


6. Click Enable Cloud Messaging.


7. Copy the Server API Key and Sender ID to somewhere safe or just leave the window open.


Now, we need to update the Fiori Mobile App Settings with the GCM Keys and rebuild the app.

1. Open the Mobile Secure Cockpit (from HCP Services, select the Fiori Mobile Tile, then select Go To Admin Console)


2. Select Manage Apps in the Main Navigator, then select your Product Listing App


3. Select the App Settings tab, Notifications, and expand the Android Section. Enter your Server API Key and Sender ID that you just created from the Google Developer Site, then Save.


4. Go to the Platforms tab, right click the gear on the Android OS line and select Build.


5. Once the build is complete you can go to Mobile Place on your Android device and download the new version.

NOTE: Your SAP Mobile Place URL is available via HCP Cockpit > Services > Fiori Mobile > “Go to Mobile Place” or try https://<trial-p#trial> (only replace p# which is your trial id)

From the Mobile Place, if the app is not listed click the Menu Button, Expand My Profile, and select Fiori Mobile Apps. When the apps are presented, click the download button for your Product Listing.


6. Once downloaded, install the app and then launch it. Click the Product Listing Tile and the app will open. Click the Register Button and if all goes well you will get a Success message.


Continued Here…

Assigned Tags

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

      Good one Steve 🙂 . Thanks.

      Author's profile photo Lalit Sharma
      Lalit Sharma

      Thanks a lot Steve for putting this together. It works perfectly!

      Author's profile photo Vishnupriya Varadharajan
      Vishnupriya Varadharajan

      Thanks Steve for this wonderful and well explained article. I am getting "Registration failed - Cannot access Server" error when trying to register for Push Notification. Followed the steps explained here. Not sure what is causing this error. Any suggestions?

      Author's profile photo Daniel Silva
      Daniel Silva

      I have the same error!

      Author's profile photo Former Member
      Former Member


      Can we open the app without going through the fiori launchpad?



      Author's profile photo Michael Appleby
      Michael Appleby

      Unless you are asking for clarification/correction of some part of the Document, please create a new Discussion marked as a Question.  The Comments section of a Blog (or Document) is not the right vehicle for asking questions as the results are not easily searchable.  Once your issue is solved, a Discussion with the solution (and marked with Correct Answer) makes the results visible to others experiencing a similar problem.  If a blog or document is related, put in a link.  Read the Getting Started documents (link at the top right) including the Rules of Engagement. 

      NOTE: Getting the link is easy enough for both the author and Blog.  Simply MouseOver the item, Right Click, and select Copy Shortcut.  Paste it into your Discussion.  You can also click on the url after pasting.  Click on the A to expand the options and select T (on the right) to Auto-Title the url.

      Thanks, Mike (Moderator)

      SAP Technology RIG

      Author's profile photo Former Member
      Former Member

      Dear Steve,

      I am also getting the same error "Push Registration failed – Cannot access Server". If anyone of you have resolved this issue please let me know.

      Author's profile photo Former Member
      Former Member

      Hi Steve,

      I have successfully integrated Push notification mobile service for Android enabled mobile devices.

      but I am not be able to find any process for building same application on ios platform.

      I have few questions as well.

      • Whether we are using same AFC for ios build configuration ?
      • is there any other specific steps for configuring ios build ?

      I have all the required things related to ios signing profile.

      I have tried using it but the build gets failed every time,build logs are getting generated but i am not be able to find any error inside that file.

      Can you please help me in this ?

      Thanks in advance !