question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: window.Ionic.platforms returns ['mobile', 'mobileweb'] instead of ['desktop'] on chromium based browser

See original GitHub issue

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x
  • Nightly

Current Behavior

On Chrome desktop browser, I use isPlatform('desktop') but it always return false and my app always behaves as a mobile one. Same problem with recent Chromium or Edge browser but no problems on Firefox.

Expected Behavior

isPlatform('desktop') should return true on chromium desktop browsers

Steps to Reproduce

  • Build an Ionic project
  • run it on a chrome browser
  • open console and type : window.Ionic.platforms

You can try it on any Ionic project, like https://www.justwatch.com/ (not mine, just an example)

You will see that this return [‘mobile’, ‘mobileweb’]

Code Reproduction URL

No response

Ionic Info

Ionic:

Ionic CLI : 6.10.1

Utility:

cordova-res : 0.15.1 native-run : 1.0.0

System:

NodeJS : v16.13.2 npm : 8.1.2 OS : Windows 10

Additional Information

When I browse source code here const isMobile = (win: Window) => matchMedia(win, ‘(any-pointer:coarse)’);

I tried window.matchMedia?.('(any-pointer:coarse)').matches in both Chrome and Firefox: Chrome returns true, and Firefox false

Maybe it is problem with Chromium ?

Chrome version: 103.0.5060.114 Firefox version: 102.0.1

PS: I checked that I am not in a mobile debug mode before posting this issue 😛

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
cyril-colincommented, Jul 13, 2022

Nope, no touch screen, but a waiting Windows Update: I am now on the build 22000.795 (instead of 22000.739) and it works like a charm

Sorry for the waste of time !

1reaction
cyril-colincommented, Jul 13, 2022

Ow… the bug seems to be only on my computer: an other windows 11 PC with same chrome version has no problem…

I’ll be back with more information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: getPlatforms() returning incorrect platforms · Issue #19942
I've tested in a new ionic angular app created with "ionic start myApp tabs". On other mobile phones the same app returns "mobile"...
Read more >
Why is Ionic Platform showing Laptops as Mobile/Tablet?
We have a an angular Ionic app that renders differently for Mobile and Desktop. We are experiencing issues with users on Microsoft Surface ......
Read more >
Desktop returns 'mobileweb' as platform for Ionic apps
When my app runs on certain desktops(Windows-touchscreen) the Platform calss doesn't return 'desktop' as platform, instead it returns ...
Read more >
The 9 Most Common Mistakes That Ionic Developers Make
Common Mistake #2: Not Using the Ionic CLI to Install Platforms and Plugins. Ionic CLI adds features to the Cordova CLI. Platforms and...
Read more >
20587 - Window class for web apps should be different from ...
Issue 20587: Window class for web apps should be different from browser window (need StartupWMClass in generated .desktop entries).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found