The discussion addresses the issue that Discourse’s mobile device detection logic is too strict, failing to identify certain Android devices like LG phones and the Nexus 7 as mobile. charleswalter initiated the thread by noting that LG devices were not being detected, while codinghorror confirmed that the Nexus 7 was previously detected as mobile but is no longer. sam explained that the current detection algorithm is intentionally simple, linking to the source code. Mittineague suggested adding a manual “switch to mobile view” option for desktop users, a feature codinghorror noted already exists. evantill reported display issues on an iPhone 6 Plus, which codinghorror attributed to unusual configurations, though sam later confirmed a workaround for evantill. charleswalter proposed using the Wurfl service for better detection, but codinghorror rejected this due to the desire to avoid external dependencies. After gathering user agent strings from various devices, including the Nexus 7 and Nexus 10, codinghorror announced a change to the detection regex. The new logic will match /Mobile|Android|webOS/ while explicitly excluding iPads and larger Nexus tablets (9 and 10). This update aims to prioritize the mobile layout for the vast majority of Android phones and phablets, accepting the minor risk of misclassifying rare full-size Android tablets as mobile. Sailsman63 and sam discussed the complexity of shifting detection to client-side viewport dimensions, concluding the server-side regex update was the preferred solution.
Has there been any thought on reviewing how Discourse detects mobile devices? I was checking in my Chrome developer tools, and it doesn’t appear that LG devices are detected as mobile. I haven’t tested on a Samsung S6 or Motorola devices.
So it all just depends on how far we want to push this. Also it may make sense just to do the switch based on screen width in the client side, but it would change a big pile of things.
Maybe the simplest would be to have a “switch to mobile view” option for desktop view similar to the “switch to desktop view” that mobile view has?
IMHO it would still be good to have some detection in place, but for those that fall through the cracks I think there would be a better chance of them finding a “switch” link than it would be for them to realize they need to do a ?mobile_view=1
We should auto-detect mobile in Android Chrome and Android Firefox on Android (because Android tablets, LOL) and we can test this on our team Nexus 6p devices + the Nexus 7 devices..
We should auto-detect mobile in Mobile Safari on 2012+ iOS 8,9 handheld devices
You must have some unusual setup in Safari, or unusual site configuration – I have never seen any Discourse site have trouble auto-selecting the mobile layout on iPhone.. ever.
Would discourse ever consider leveraging a service like wurfl? or making this an option for admins in settings?
“You can use the service free of charge, as long as your website is publicly available and does not require fees or paid subscription to access. Read the complete license here.”
Also — anyone reading this who wants better android mobile device detection, please visit this site with the target device and paste in your results here, along with the specific make / model of your device as well as OS / browser version.
If you ever click to view in desktop mode, it remembers forever. Do you get this issue when you browse incognito? Try going to hamburger and selecting mobile view.