Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SAPUI5: What is the best Reliable way to detect on which device my app is running?

Hi,

I have developed a sapui5 app that can run on iPhone, iPad, and desktop. Depending on the running media, it will use different theme or UIs. The are several ways of detecting OS, device or screen resolutions, such as:

    navigator.userAgent.match(/(iPhone)/g)

    window.devicePixelRatio ==2

    scree.width()

    iQuery.device.is.phone

    $('#phone').css('display') == 'none'

My question: what is the best and Reliable way in the code to find out which of the following devices my app is running on:

   "iPhone" (valid for all kinds of resolutions)

   "iPad" (all possible types)

   "laptop/desktop"

Thanks.

Sr. Sys Developer●Enterprise Mobility●SAP●iOS●Web●Android

Tags:
Former Member
replied

Hi,

the sole purpose of this Device API is the detection of different device/platform characteristics, so it should be reliable or will be fixed in case it is not.

Just be sure to understand the detection it does. E.g. for Android phones and tablets: where is the border? Is a Galaxy Note a phone or a tablet? Or the Microsoft Surface tablets, are they really tablets - they can have a keyboard - or are they laptops (="desktop")? So the decision is not always clear, but the API has its defined behavior for these edge cases.

For iPhone/iPad the decision is very clear, though.

Standalone detection is not part of the API.

Regards

Andreas

1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question