Skip to Content

There are so many features available in SAP Cloud Platform, Mobile Service for Development & Operations and one of them is “Predefined Push for SAP Fiori Client“. But how does it work? What all are per-requisite / Configuration required for this?

 

Well, idea of writing this blog post has come after looking into a question asked by a community member on twitter , glad that he asked it.

Fyi: SAP Fiori Client is (Free) standard native application (iOS, Android, Windows) that enables you to run web application (or consume Fiori-based applications) as online hybrid apps. Check here for more information.

There is already  lots of information posted by Daniel Van Leeuwen in his blog where you can learn how to build, run, customize Fiori Client and many more.

But below write-up covers some important information for above mentioned feature. This feature works only with standard Fiori Client application.

In order to work/test that feature, you should have a running UI5 or Fiori-like application. Quick way to do>

  1. a create a simple SAPUI5 app in SAP Web IDE.
  2. Add below code in the index.html ( intial application page that Fiori client displays )
<!-- Push notificaiton -->
    <script>
        function onSapLogonSuccess() {
            alert("EventLogging: onSapLogonSuccess");
            initPush();
        }
function initPush() {
            alert("EventLogging: initPush");
            sap.Push.initPush(processNotification);
        }
function processNotification(notification) {
            alert("in processNotification: " + JSON.stringify(notification));
            if (sap.Push.setPushFeedbackStatus && notification.additionalData) {  //SP15 new feature
                sap.Push.setPushFeedbackStatus('consumed', notification.additionalData.notificationId, pushFeedbackStatusSuccessCallback, pushFeedbackStatusErrorCallback);
            }
        }
        
        document.addEventListener("onSapLogonSuccess", onSapLogonSuccess, false);
    </script>
<!-- Push notificaiton -->

Note: The page Fiori Client displays should contain logic to register for Push notifications,  above code is for register for Push notifications and also it contains a method that gets called when the notification arrives.

 

 3. Deploy above UI5 app to SAP Cloud Platform

 4. In Mobile Services (Development & Operations) Cockpit, create an app (give it some name com.test.fc1)

  • By default, app is assigned to SAML security provider
  • Under Connectivity, enter URL as generated from step#3

 

  • Select predefined for PUSH client option under Push notifications

5. Download Standard “SAP Fiori” app from appstore

6. Enter URL as https://hcpms-xxxxxxtrial.hanatrial.ondemand.com/com.test.fc1?appid=com.test.fc1&fioriurlissmp=true&authtype=saml2.web.post

Here: host  >> Mobile service (server) URL

com.test.fc1 >> application ID created in Mobile service for development and operations (step#4)

fioriurlissmp=true >> proxying Application URL via Mobile service

authtype=saml2.web.post >> since my app is configured with SAML authentication provider as    mentioned in step#4

(there is also an alternate way in SAP Fiori Client to scan QR code so rather than entering URL or sending it via emails, you can generated its QR code , for this i used http://goqr.me/ )

7. Go through steps as shown here

8. Above steps also include user-on-boarding on Mobile service, to verify this, click in application configuration in Mobile service cockpit, go to “user Registration” tab , here you would fine registration ID ( or we call it X-SMP-APPCID )

9. In order to send notification to this user , select checkbox in front of registration ID 23e81….. and click on “Sending Notification” option . Write a message in this new window and click on “Send”.

 

Once you confirm above dialog, you should able to see notification reaching to your device

 

 

This is all above this feature, predefined push for Fiori Client.

 

Additional Info:

 

(1)

Here in above configurations , you might have noticed that nowhere we added any APNS (since my Fiori client is running on iOS device) configuration, well, mobile service under the hood taking care of registering device to APNS, getting token ID from there and storing it to the respective registration ID. So lets cross check it:

Since we have already got registration ID for user, lets make a GET call in a REST client

URL : https://hcpms-xxxxtrial.hanatrial.ondemand.com/odata/applications/v4/com.test.fc1/Connections(’23e81ea2-ee7f-4926-af44-f6281773a5c0′)

Headers: Authorization: username and password

X-SMP-APPCID : 23e81ea2-ee7f-4926-af44-f6281773a5c0

 

in response, you should see ApnsPushEnable as true and ApnsDeviceToken value.

 

(2)

 

You can also send push message from REST client itself

  1. https://hcpms-xxxxxxtrial.hanatrial.ondemand.com/restnotification/application/com.test.fc1
  2. POSTmethod
  3. Header:
    1. Authorization : Basic
    2. content-type : application/json
  4. Payload >>{“alert”:”notif from REST client”, “data”:”For 123″, “badge”:2}
  5. make sure user entered under Authorization header should have “notification user” role. Go to “Configure Development and operations” > Roles > select Notification User role > assign userID

 

Thanks Daniel Van Leeuwen & Martin Grasshoff for your inputs.

Jitendra Kansal

Product Management, SAP Cloud Platform User Experience
SAP SE

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Christian Tapia

    Hello Jitendra!

    I’d like to share that I got the push notifications working with Predefined Config for Fiori Client without adding any code. I’m not sure what are the prerequisites for this to work, but in my case I deployed the app via a Fiori Launchpad (registered as Fiori Destionation in SCPms):

    And also added these parameters to the URL:

    • &appID=com.test.testapp
    • &hcpmsroute=mobileservices
    • &authtype=saml2.web.post

    I will try to figure out what is making this happen.

    (0) 

Leave a Reply