Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert

For latest information, please visit documentation


 

 

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.vanleeuwen 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. Enforce NoAuth for this app (please note, this option is selected for this demo only)


in neo-app.json file added authenticationMethod as none
{
"welcomeFile": "/webapp/index.html",
"authenticationMethod": "none",
"routes": [
{
"path": "/resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/resources"
},
"description": "SAPUI5 Resources"
},
{
"path": "/test-resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/test-resources"
},
"description": "SAPUI5 Test Resources"
}
],
"sendWelcomeFileRedirect": true
}

4. Deploy above UI5 app to SAP Cloud Platform


5. 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




6. Download Standard "SAP Fiori" app from appstore

7. Enter URL as https://hcpms-xxxxxxtrial.hanatrial.ondemand.com/com.test.fc1?appid=com.test.fc1&fioriurlissmp=true&...

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/ )

8. Go through steps as shown here



9. 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 )



10. 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('23e81...

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.vanleeuwen & martingrasshoff for your inputs.

Jitendra Kansal

Product Management, SAP Cloud Platform User Experience
SAP SE
14 Comments
christian102094
Participant
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.
Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos
ctapisab

can you share URL you entered in FC app ?

 
christian102094
Participant
SimoneCattozzi
Participant
0 Kudos
Could you provide some steps to achieve the correct configuration?

Thank you
MikeDoyle
Active Contributor
This is an exciting feature jitendrakumar.kansal, thanks for writing the blog.

Could you please clarify where the index.html resides and how we reference it?  Fiori apps don't need an index.html as the launchpad runs them as components.  Is this a launchpad-specific index.html?  Do we add the logic in a shell plugin for example?  I'm familiar with entering the launchpad url when you first launch the Fiori Client, but are you talking about something different here?

Do we get full functionality to handle push notifications in the Fiori Client, or is there something missing compared to using a native app?  I assume that we can build a url to navigate to, based on the payload?  For example if a push notification arrives asking me to approve PO #123 I assume I can get the launchpad to navigate to 'PO-Approve&/Item/123', for example?  I would need to be able to update the index.html as I added more apps to my launchpad.

Why is this only supported for the standard client?  It seems a bit limiting that customers can't add their own branding to the client and use push notifications.

 
snursalim
Participant
0 Kudos
Why is this only supported for the standard client?  It seems a bit limiting that customers can’t add their own branding to the client and use push notifications. -> I guess because SAP wanted to get people to on-board to their cloud platform or purchase their mobile services license.

 

I did some POC for my company on this Push Notification through the SAP Mobile Services, it works beautifully, problem is the cost impact is such a turn off because you'd need to purchase additional Mobile Service license on top of existing SAP ERP licenses.

 

I hope they come up with some alternative on this, because I can actually see them earning additional ERP license as company would be interested to roll out mobile capability to their mobile worker (which most probably don't have SAP license in the first place e.g: Sales People).
SAPAI
Participant
0 Kudos
Hi Christian,

Could you please share some steps/docs on how you achieved these with SCPms and fiori app in fiori launchpad?
I am trying same but seems like missing some connecting dots.. Appreciate if you could provide the steps and details.

 

Thanks,

Asif.
0 Kudos
Hi Mike,

Did you get to know answers to your queries (i)is this a launchpad-specific index.html?, (ii)do we get full functionality to handle push notifications in the Fiori Client. I have similar queries, please help me with the same.

Regards,

Pradip
MikeDoyle
Active Contributor
0 Kudos
No, I didn't get any answers
0 Kudos
Hi Suwardi,

If we have standard fiori applications like approve purchase orders, approve purchase requests etc running on the fiori client on mobile, how can we get the push notification on the mobile for every purchase order or purchase request? Do we need to configure push notifications for the standard fiori application on HCPms -  in that case, how will the notifications be pushed to the fiori client  on mobile? or do we need to configure push notifications for the fiori client on HCPms - will that work? Please help me understand how we cam make this work.

Thanks,

Pradip
0 Kudos

Hi ctapia & jitendrakumar.kansal

I tried the same thing that christian suggested i.e registered cloud portal(FLP) url in the connectivity section of the newly created app in mobile services, as a result the notifications works in the fiori client. Need two clarifications now

  1. The fiori client runs in the restricted mode due to a cors url kind of an issue.
  2. Which api should we use if we want to get the list of users registered for a app in abap before sending the post request from abap client.

Many thanks

christian102094
Participant
0 Kudos
Hello architwahi,

  1. I'm not aware of this issue 😞

  2. Not sure if there is an API for this. What we have been doing in our apps is to send notifications to specific users and not many, but maybe is there another way to get that list of users? Maybe register them programatically in a backend table?


Sorry if I can't help more.

Best regards.
0 Kudos
Hi ctapia

  1. How cum you didnt see the restricted mode in fiori client. You have also registered the cloud portal LP url in the mobile services app section right??the restricted mode doesnt let you use native mobile functions like cam etc.

  2. I believe there should (guess there is) an api to get list of users from mobile services for that app so we can dynamically send notifications to this users using:


http[s]:// <HMC base URL>/restnotification/registration
'{
"notification": {
"alert": "TravelAgencies",
"data": "Notification to list of registrations",
"sound": "default"
},
"registrations": [
"0ca01d28-8f48-4c38-8764-c6b72d40d434"
] OR

restnotification/application/com.sap.ios.sdk.onboarding/user/

"users": [
"d056936",
"user1"
]
}

Else only workaround is that we use a diff odata svc to save data in backend while we are registering users on cloud.

Also These are the url you also might be using right? How are you sending notifications to users, can you share your method?

 

Many thanks

 

 
christian102094
Participant
0 Kudos
Hello,

Here is the code:
METHOD send_native_notif.
DATA:
ls_payload TYPE string,
ls_payload_x TYPE xstring.

DATA(ls_url) = |https://mobile-{ ip_subaccount }.{ ip_region }.hana.ondemand.com/restnotification| &&
|/application/{ ip_scpms_app_id }/user/{ ip_user }|.

cl_http_client=>create_by_url(
EXPORTING
url = ls_url
IMPORTING
client = DATA(lo_http_client)
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4 ).
IF sy-subrc <> 0.
RETURN.
ENDIF.

lo_http_client->authenticate(
username = ip_scpms_user
password = ip_scpms_pw
).
IF ip_text IS INITIAL.
ls_payload = |\{"badge":"{ ip_badge_count }"\}|.
ELSE.
ls_payload = |\{"alert":"{ ip_text }","data":"{ ip_data }","badge":"{ ip_badge_count }"\}|.
ENDIF.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = ls_payload
IMPORTING
buffer = ls_payload_x.

lo_http_client->request->set_method( 'POST' ).
lo_http_client->request->set_content_type( 'application/json' ).
lo_http_client->request->set_data( ls_payload_x ).

lo_http_client->send(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2 ).

lo_http_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3 ).

DATA(ls_response) = lo_http_client->response->get_cdata( ).
" TODO Retornar mensaje?
ENDMETHOD.

Best regards.