hisorange / browser-detect

Browser Detection for Laravel by hisorange!
https://browser-detect.com
MIT License
1.08k stars 143 forks source link

Doesn't detect certain mobile devices #190

Closed Siropu closed 2 years ago

Siropu commented 2 years ago

I have made some tests using an Android Xiaomi Redmi Note 10 Pro and it is not recognized as a mobile device.

Mozilla/5.0 (Linux; Android 12; M2101K6G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[103.0.0.0](http://103.0.0.0/) Mobile Safari/537.36

hisorange commented 2 years ago

Hello,

Mobile recognition is tricky as the note is more of a phablet. It's recognized as tablet, https://browser-detect.com/?agent=Mozilla/5.0%20(Linux;%20Android%2012;%20M2101K6G)%20AppleWebKit/537.36%20(KHTML,%20like%20Gecko)%20Chrome/[103.0.0.0](http://103.0.0.0/)%20Mobile%20Safari/537.36

I would advice to either check for !isDesktop or check (isMobile || isTablet)

Usually tablets are managed the same way as mobiles, since on server side you can't tell how big is the screen and what is the resolution.

Siropu commented 2 years ago

This package uses mobiledetect.net library right? On their site, the demo correctly detects my device as a mobile phone device.

hisorange commented 2 years ago

Not just, it uses 4 different package as some of them defines mobile differently, and the tablet detection is the hardest, as it's depends on definition. Some of the library says a Note 10 is a tablet, some of them says it's a mobile.

And I kinda get it, you literally have to look at the device to tell it, but as you can see from the string it's not a device definition so a tablet can send the exact same UA and from there on, you can only tell the diff by javascript.

hisorange commented 2 years ago

The "Mobile Safari" string is used both on tablets and mobiles :/