Persisting desktop/mobile view in mobile Chrome browsers

I have both an Android phone & tablet, running the latest releases of Android/Chrome.

On the Pixel C, my standard orientation is landscape with a keyboard, so the mobile UI is not ideal. I keep trying the “request desktop version” in the browser options, but really wish that I didn’t have to do this step every single time I load a Discourse site.

Is there any way to persist the mobile/desktop preferences based on a cookie or something?

1 Like

Yes, but that cookie would be per domain so how would it help? The real issue is, freakishly rare android tablet, does it send a unique agent like the Nexus series do?

1 Like

I guess it would help by keeping the desktop UI setting every time I went to mydiscoursesite.example.org in my Android Chrome browser. Isn’t that desirable?

And, yes, unique user agent indeed:

Mozilla/5.0 (Linux; Android 6.0.1; Pixel C Build/MXC14G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Safari/537.36

I think the call here is to always ask for Mobile + Android for Android mobile detection, if we need to whitelist some more 7’’ tablets (so they are treated as mobile) then we can

3 Likes

There are some specific Google Chrome user agent detection recommendations for “Phone” vs “Tablet” listed here:

https://developer.chrome.com/multidevice/user-agent

  • Phone pattern: Android + Chrome/[.0-9]* Mobile
  • Tablet pattern: Android + Chrome/[.0-9]* (?!Mobile)
2 Likes

All right, I’m changing it to

user_agent =~ /Mobile/ && !(user_agent =~ /iPad/)

No idea why we had webOS in there, who even uses that? Let’s just say it’s a mobile device if it is telling us it is one:

Mobile

5 Likes

This topic was automatically closed after 2 days. New replies are no longer allowed.