browser-detect icon indicating copy to clipboard operation
browser-detect copied to clipboard

Browser::isMac() does not seem to work on some UA with iPad/iPod/iPhone in it

Open darkylmnx opened this issue 2 years ago • 2 comments

I have some UA that were iPhone's or iPad's but that were reported false with ìsMac`.

Eg:

  • Mozilla/5.0 (iPad; CPU OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1
  • Mozilla/5.0 (iPad; CPU OS 14_8_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1

Both of these aren't working while despite the following working and having the same signature :

  • Mozilla/5.0 (iPad; CPU OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13G36 Safari/601.1

Any idea what's going wrong?

darkylmnx avatar Nov 26 '22 00:11 darkylmnx

Yep, but technically it's not MacOS, even tho it seems a bit of. But the iPhone runs iOS and iPad runs iPadOS, MacOS is used on laptops and desktops only.

I know the text includes the string, but it would be better to test for "isAppleOS", gonna keep this open for the next minor release, as I see the use case for it.

hisorange avatar Sep 22 '23 22:09 hisorange

https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent

Serving different Web pages or services to different browsers is usually a bad idea. Note: It's worth re-iterating: it's very rarely a good idea to use user agent sniffing. You can almost always find a better, more broadly compatible way to solve your problem!

nekromoff avatar Aug 17 '24 12:08 nekromoff