[SOLVED] "pc.platform.desktop" returning true for Samsung internet browser on Samsung Galaxy Tab S8 v12.0

“pc.platform.desktop” is returning true for Samsung internet browser on Samsung Galaxy Tab S8 v12.0.
Is there a way to detect for this device if it is mobile?

This may be because of the browser User Agent is describing itself as a desktop browser which is common for tablets.

It’s difficult to really tell effectively if it’s an Android/iOS tablet just from the user agent these days without some not so nice checks. Stackoverflow will have a number of these possibilities.

Why do you need to know? Perhaps there’s a better check to do based on why you need it? Eg if it’s because you want to check for touch screen, then it would be better to check if the user interacts with touch rather than a mouse.

The requirement is for the Desktop users to show a pop up and not allow to play the game as it is mobile exclusive.
Samsung Browser on Tab is showing the pop up that should not be the case.

But why?

Edit: You can check the usage agent if it has SamsungBrowser in the text but really you are fighting against what the browser chooses to identify as.

I would look at locking out users via feature access instead

You can try something like this: https://github.com/hgoebl/mobile-detect.js and see if you get any better luck

It identifies the Samsung Browsers hence Samsung Tab is detected as well.
It worked for me.

1 Like

Be warned iPad OS on iPads also report as desktop browser so you will need to cater for that too

1 Like

I have fixed that as well

if (window.devicePixelRatio == 2 && navigator.maxTouchPoints > 0) { // IPad

  • !pc.platform.desktop
  • iPad Fix
  • Samsung Browser Tab Fix

Combined all these checks , all mobile device are being covered in these that we tested on.

1 Like