15

I have a web page that when viewed from an iOS device displays slightly different content. To detect the device in question the site looks for iPad;, iPod;, or iPhone; in the user agent string.

This works perfectly on Safari on all iOS devices. Testing with Chrome for iOS it works on iPhone and iPad 1, but not iPad 3. The web site is getting the following (unexpected) user-agent string:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.53.11 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10

This seems to be related to the "request desktop site" option in the chrome menu (what would be the wrench icon in desktop chrome). For my site it's disabled and seems to be locked to the desktop rather than mobile site. For other sites, it's enabled and results in a different user-agent string being sent when selected. eg: try http://ifconfig.me/all

So my questions are:

  • what criteria does Chrome use to decide whether to enable this option
  • given that Chrome has forced this site to the desktop site, how do I render iOS specific content (in my case a link using a protocol that is handled by my app)

If you'd like to test this yourself, there's a page here that simply reflects the user-agent string.

Brad Robinson
  • 44,114
  • 19
  • 59
  • 88
  • 1
    Chrome for iOS on my iPad 3 shows a string different from what you write above. It includes "CriOS", as expected. – Zade Oct 05 '12 at 19:03
  • Thanks for asking this. We just ran into this one today but only on one iPhone running 6.1.3. – Alex Zavatone Sep 03 '13 at 17:38
  • Thanks for the link to User Agent detection. BTW, Chrome User Agent strings are documented here - https://developer.chrome.com/multidevice/user-agent – Ilia Barahovsky Jan 08 '15 at 14:16
  • If the iOS/Chrome user agent mess doesn't look strange enough already... see if this messes with your head... the version of Chrome for iOS is not actually Chrome at all but Safari's engine with a Chrome 'skin' -- One article about that is here: http://allthingsd.com/20120628/googles-chrome-for-ios-is-more-like-a-chrome-plated-apple/ Important to know as a developer with hardware issues. – Jeff Clayton Mar 03 '15 at 05:47

1 Answers1

14

The browser will switch between using the two User Agent strings based on whether you are acting as a mobile browser of masquerading as the desktop browser.

User Agent:

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

User Agent after "Request desktop version":

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3)
AppleWebKit/534.53.11 (KHTML, like Gecko)
Version/5.1.3 Safari/534.53.10

This is only a hint to the web server about who the client is. The browser should render the received web content independently of the User Agent.

don
  • 1,497
  • 1
  • 13
  • 27