Showing results for 
Search instead for 
Did you mean: 

[SAP MDK] Retrieving Mobile's Domain name of the host

0 Kudos

Hello MDK Community,

I am currently developing an application using the SAP Mobile Development Kit (MDK) and I am facing a challenge in retrieving the host name (of mobile devices) during runtime.

The objective is to programmatically determine the host name of the device within my MDK application. This information is critical to implement custom logic for environment-specific routing.

Thus far, I have:

  • Reviewed MDK client API reference for any mention of network or host information.
  • Searched through various online examples and SAP community threads without much luck.

Additionally, I'm aware that for the WebApp, it's possible to retrieve the host by using the following JavaScript line:

const hostnameElements = window.location.hostname;
//output: ‘'

However, this method work only on WebApp and fail to function on mobile devices, as it's not compatible with NativeScript used by the MDK on mobile platforms.
What I need is an alternative method that works on MDK clients within a mobile environment.

To provide some background on the issue: The purpose of retrieving the hostname is to determine the environment in which the app is running. For instance, if the hostname contains the term "dev," then the app should open a specific URL associated with the Development environment. Similarly, if the hostname contains "qas" or "prod," it should open a link tailored for the QAS or Prod environments respectively.

If anyone has insights on accessing the mobile host information in an MDK environment or knows of any workaround to achieve a similar result as window.location.hostname on the web, your guidance would be greatly valued.

For reference, I'm using SAP Mobile Services for the backend orchestration and the latest MDK client version.
Thank you in advance for your assistance!

Best regards, Khaled

View Entire Topic
Product and Topic Expert
Product and Topic Expert
0 Kudos

Have you tried calling clientAPI.getMobileServiceEndpointUrl()?  You can also call clientAPI.getMobileServiceAppId() to get the app id in mobileServices as well.