Mobile-Detect icon indicating copy to clipboard operation
Mobile-Detect copied to clipboard

Chrome's user agent reduction results in no longer detecting Android tablets as a tablet device

Open AdmDevelopment opened this issue 8 months ago • 1 comments

Thanks to Chrome's "user agent reduction" the user agent in Chrome no longer contains dynamic device and operating system information. For Android the operating system is fixed as Android 10 and the device model is set to K. The only thing that appears to be dynamic is the Major Version of Chrome. They did this to combat fingerprinting.

More info: https://developer.chrome.com/blog/user-agent-reduction-android-model-and-version/

The user agents are:

Android Tablet using Chrome: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{MAJOR_VERSION}.0.0.0 Safari/537.36

Android Smartphone using Chrome: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{MAJOR_VERSION}.0.0.0 Mobile Safari/537.36

Replace {MAJOR_VERSION} with 117 for the user agent in Chrome 117 on android devices.

On Android tablet devices the isMobile() method currently returns true since "Android" matched, however isTablet() fails to detect the tablet device.

I added the following to $tabletDevices in MobileDetect v4.8.02 to detect the Android tablets using Chrome: "ChromeUserAgentReductionAndroidTablet" => 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/(\d+).0.0.0 Safari/537.36'

I used the complete user agent since it should be static except the Major Version.

It appears they are now storing specific information inside User Agent Client Hints in the HTTP headers: https://web.dev/articles/migrate-to-ua-ch

AdmDevelopment avatar Oct 12 '23 09:10 AdmDevelopment