Android mobile device detection is too strict

Thank you @sam. Seems to solve my problem :pray:

All right here’s what we have had

user_agent =~ /Mobile|webOS|Nexus (5|6|7)/ && !(user_agent =~ /iPad/)

Here is what I am changing it to:

user_agent =~ /Mobile|Android|webOS/ && !(user_agent =~ /iPad|Nexus (9|10)/)

My iPhone 6s β€” matches Mobile

Mozilla/5.0 (iPhone; CPU iPhone OS 9_2_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13D15 Safari/601.1

My Nexus 7 β€” matches Android

Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MMB29Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Safari/537.36

Nexus 10 β€” not-matches Nexus 10

Mozilla/5.0 (Linux; Android 5.1.1; Nexus 10 Build/LMY49G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Safari/537.36

(this same regex is duplicated in two places, @sam said he’d clean it up)

Anyway, this broadens the matching substantially for Android. I am very fine with prioritizing phone and phablet layout for Android, as tablets are really a non-starter in the Android space. We feel it is the far lesser evil to have the (rare) Android full size tablet detected as mobile by mistake, than have one of the trillions of random Android phone models out there be detected as desktop by mistake.

6 Likes

GALAXY S7 CHROME

A Analyze
Mozilla/5.0 (Linux; Android 6.0.1; SM-G930V Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Mobile Safari/537.36

1 Like

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