Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Scott (@scottsweb)

    (@scottsweb)

    Hi David
    That is a tricky one. mobile_detect.php works by sniffing the browser user agent. You could try adding <?php echo $_SERVER['HTTP_USER_AGENT']; ?> to the footer of your theme and then visit the site on desktop and mobile to see what the differences (if any) in the user agent are.

    With that you could then begin to create your own function which checks for one and not the other.

    Post back if you manage to get both user agent strings and need some help working it out.

    Hello all, I confirm, no Chrome on IOS !
    Too complicate for me. Did one of you found the solution ?
    Thanks.

    According to Dave at Shellcreeper, the user agent string for Chrome on an Android is:

    Mozilla/5.0 (Linux; Android 4.1.2; New Andromax-i Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.90 Mobile Safari/537.36

    I am assuming the user string would be fairly close to that and the following code should detect it:

    If( is_ios() && is_chrome() ) {
        // then do some iOS chrome browser stuff
    } else ...

    See Better Responsive Design with wp_is_mobile, Why Responsive Design is Not Enough

    One UserAgent string for iOS and Chrome is:

    Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; da-dk) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3

    There is a list of UserAgent strings being maintained at a support thread for the Firefox UserAgent Switcher list, an extension for Firefox and last updated on Jan-9-2015.

    You will notice that the Chrome browser is identified as CriOS and not Chrome. The current version of mobile-detect.php in the plugin does correctly identify that as a Chrome browser, so no problem there.

    Scott,

    I found the problem for detecting Chrome on iOS. It is due to the logic in the WP include file vars.php which sets the $is_chrome variable. It only searches the UA string for the word ‘Chrome’ and not the other browser names such as ‘CriOS’ and ‘CrMo’.

    Your plugin relies on the $is_chrome global to add it to the body class. You also rely on other simple browser checks for gecko, IE, opera, etc.

    You could use their Beta feature function Mobile_Detect::is() rather than the globals from WordPress. You can test for all of the global equivalents and more with the mobile detection file.

    Plugin Author Scott (@scottsweb)

    (@scottsweb)

    Thanks for letting me know. I have done some testing this afternoon (see commented out code here: https://github.com/scottsweb/mobble/blob/master/mobble.php#L437-L449) and Mobile_Detect::is() didn’t do a very good job for me at detecting Chrome, Firefox etc.

    I am going to sit on this a while and see if a new update to the library fixes things. I have reported a few inconsistencies today and you can do the same here: https://demo.mobiledetect.net/

    Thanks for that link. I noticed that it didn’t correctly identify my desktop browser as Firefox.

    It did do well for the iPad, and correctly identified the Chrome and Safari browsers.

    Plugin Author Scott (@scottsweb)

    (@scottsweb)

    Interesting. Perhaps we should use both core WP and mobile detect to add the body classes for now then. I have committed this to GitHub and you are welcome to test:

    https://github.com/scottsweb/mobble/archive/master.zip

    Thanks for your help debugging.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Chrome for iOS not being detected’ is closed to new replies.