serbanghita / Mobile-Detect

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
http://mobiledetect.net
MIT License
10.52k stars 2.67k forks source link

$detect->isTablet() not working #330

Closed poxa closed 9 years ago

poxa commented 9 years ago

Hi there ($i trăiască $$$erban $$$efu' la bani!), ăăă.. După cum zicea și colegul meu Alex într-un thread pe care l-ai închis și probabil că nu mai primești notificari pe el:

I'm using your script to differentiate between mobiles and tablets, but I'm having a problem in detecting the Table users. The method $detect->isTablet() should return true if the user access the page from a tablet right? I tested the function by using some online emulators like : http://tablet-emulator.org/ and http://mobiletest.me, and also by changing the user agent of the browser... But the method still returns false in all the cases. Am I doing something wrong?

Thank you in advance ;)

Alex & Poxa

serbanghita commented 9 years ago

Hi Poxa!

Sorry, I was AFK for a while. The problem with these emulators is that they are just some iframes. Check the website http://demo.mobiledetect.net in both emulators to see that it's your User-Agent. That is why they cannot be detected. You would have to use a real emulator like browserstack.com

CodeWoken commented 9 years ago

Hello and thank you for your answer

Your right about those wanna be emulators. I tried it with browserstack as you suggested and for some tablets indeed it worked. But, for example, for samsung galaxy tab 10 it didn't. Is there a spectrum of tablets that the library doesn't detect? maybe the new ones?

serbanghita commented 9 years ago

@RayCietoR no, it's a known problem at BrowserStack, some of the user-agents of those tablets contain no trace that that device is a tablet, but only a generic Android sdk user-agent. If you want to test the detection script use Crome -> Developers Tools -> Emulate and change the viewport and the user-agent string.