Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Chrome detection

I use Javascript code

if( (Android|webOS|iPhone|iPad|iPod|BlackBerry).test(navigator.userAgent) ) {}

for mobile device detection, but Chrome at iOS is not detected. Is there a way to detect it? Thanks.

like image 874
cr1msaun Avatar asked Dec 10 '12 19:12

cr1msaun


People also ask

Is Chrome on iOS actually Chrome?

As you might have heard, Google Chrome is now available for the iPhone and iPad, but before you get too excited, you need to realize that it isn't Chrome at all. It's Apple's Safari with a 'chrome' interface. The actual browser, the rendering, and javascript engine is 100% Apple Safari.

Is there a Find feature on iPhone Chrome?

You can do a Control-F search on an iPhone's browser by using the "On This Page," "Find in Page," or Share features. Control-F is a computer shortcut that locates specific words or phrases on a webpage or document. You can search for specific words or phrases in Safari, Google Chrome, and Messages.

What is the user agent of Chrome iOS?

# Chrome for iOS The UA in Chrome for iOS is the same as the Mobile Safari user agent, with CriOS/<ChromeRevision> instead of Version/<VersionNum> .


2 Answers

According to Google Developers, the UA string looks like this:

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

Where it differs from iOS Safari in that it says CriOS instead of Version. So this:

if(navigator.userAgent.match('CriOS')) 

Should do it.

like image 198
Bella Avatar answered Sep 18 '22 22:09

Bella


if you want simple true/false answer:

if(/CriOS/i.test(navigator.userAgent) &&
/iphone|ipod|ipad/i.test(navigator.userAgent)){
    return true;
}else{
    return false;
}
like image 24
Chen_Wayne Avatar answered Sep 19 '22 22:09

Chen_Wayne