foroco / php-browser-detection

Ultra fast PHP library to detect browser, OS, platform and device type by User-Agent parsing
MIT License
138 stars 33 forks source link

On iPad Pro not correctly detect OS and Device type #18

Closed DigitalAndSEO closed 1 year ago

DigitalAndSEO commented 2 years ago

First of all, incredible work done. Thanks.

In iPadPro with Safari it detects as "desktop" (it is believed, in my case, that it has the Catalina OS and other errors):

Array ( [os_type] => desktop [os_family] => macintosh [os_name] => MacOS [os_version] => Catalina [os_title] => MacOS Catalina [device_type] => desktop [browser_name] => Safari [browser_version] => 15.5 [browser_title] => Safari 15.5 [browser_chrome_original] => 0 [browser_firefox_original] => 0 [browser_safari_original] => 1 [browser_chromium_version] => 0 [browser_gecko_version] => 0 [browser_webkit_version] => 605.1 [browser_android_webview] => 0 [browser_ios_webview] => 0 [browser_desktop_mode] => 0 [64bits_mode] => 1 )

On iPad Pro with Chrome something similar happens:

Array ( [os_type] => mobile [os_family] => macintosh [os_name] => iOS [os_version] => 15.5 [os_title] => iOS 15.5 [device_type] => mobile [browser_name] => Chrome [browser_version] => 102 [browser_title] => Chrome 102 [browser_chrome_original] => 0 [browser_firefox_original] => 0 [browser_safari_original] => 0 [browser_chromium_version] => 0 [browser_gecko_version] => 0 [browser_webkit_version] => 605.1 [browser_android_webview] => 0 [browser_ios_webview] => 0 [browser_desktop_mode] => 0 [64bits_mode] => 1 )

On iPad Pro with Firefox something similar happens with Safari:

Array ( [os_type] => desktop [os_family] => macintosh [os_name] => MacOS [os_version] => Catalina [os_title] => MacOS Catalina [device_type] => desktop [browser_name] => Safari [browser_version] => 13.1 [browser_title] => Safari 13.1 [browser_chrome_original] => 0 [browser_firefox_original] => 0 [browser_safari_original] => 1 [browser_chromium_version] => 0 [browser_gecko_version] => 0 [browser_webkit_version] => 605.1 [browser_android_webview] => 0 [browser_ios_webview] => 0 [browser_desktop_mode] => 0 [64bits_mode] => 1 )

foroco commented 1 year ago

Hi @DigitalAndSEO ,

It's true, the iPad sends a "desktop" MacOS User-Agent by default. This is because the iPad's default launch mode is "Desktop Mode". Feature of the browsers in iOS.

You need "Desktop Mode" detection to get correct User-Agent parsing results on iOS. For "Desktop Mode" detection, the setTouchSupport() method should be called if the browser supports touch events. Touch events detection is performed by client-side JavaScript code in the target browser. https://github.com/foroco/php-browser-detection#usage