How to detect the users device type in web context?

I'm trying to detect the user's device type (Desktop, Ipad, Android) and proceed with different action in the nanoflow. If the user's device is Desktop, it will display the browse button, else it will display the take picture button. May I know is there anyway to do that? I have tried to use get device info action but somehow it shows that it is native actions and cannot be used in a web context.
2 answers

Hi Khai,

There are different solution directions possible for your challenge. An easy way is to use the profile determined by Mendix (phone/tablet/desktop).

This information is easily accessable in a microflow, using the $currentDeviceType (not in nanoflows or conditional visibility), so you can put that information via a datasource of a 'PageViewHelper' entity on your page.

You can also use the profile determined by Mendix via the CSS class that Mendix automatically puts on the body ("profile-desktop"). Give the buttons a specific class and add in your SCSS something like:

body.profile-desktop .my-button {display: none;}

And lastly, you can do your own detection via Javascript, like that's being done on and implement that in a Javascript action. Probably that's the most complex solution.

Good luck!



image.pngHello Khai,


Perhaps the javascript action GetDeviceInfo from the Marketplace module nativemobileresources can be of any use.

It gives back the following object/



Good luck