Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Using the Safari on iPhone User Agent String

A browser sends a special string, called a user agent, to websites to identify itself. The web server, or JavaScript in the downloaded webpage, detects the client’s identity and can modify its behavior accordingly. In the simplest case, the user agent string includes an application name—for example, Navigator—and version information—for example, 6.0. Safari on the desktop, Safari on iPhone, and Safari on iPod touch have their own user agent strings, too.

The Safari user agent string for iPhone is similar to the user agent string for Safari on the desktop except for two additions: It contains an iPhone platform name and the mobile version number as show in Listing 2-3.

Listing 2-3  iPhone user agent string

Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3

The parts of the Safari on iPhone user agent string shown in Listing 2-3 are as follows:

(iPhone; U; CPU like Mac OS X; en)

The platform string.

AppleWebKit/420+

The Web Kit engine build number.

Version/3.0

The Safari family version.

Mobile/1A543

The mobile version number.

Safari/419.3

The Safari build number.

Typically, you use the Web Kit build number, AppleWebKit/420+, to test for supported Web Kit HTML tags and CSS properties. The Safari family version, or marketing version, Version/3.0, is included in the user agent string for Safari on the desktop, too. Therefore, you can use it to track usage statistics across all Safari platforms.

Go to these websites to learn more about other techniques for detecting Safari and the Web Kit:



< Previous PageNext Page > Hide TOC


Last updated: 2008-02-05




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice