How to: Fake the iPhone User Agent

Posted by Andy Atkinson on October 3, 2007 | Post type: Gain

OS X users can install iPhoney or another desktop application to test iPhone compatible websites and applications. The application sets the user agent so the iPhone-specific version of a site or application can be displayed instead of the traditional theme. Web-based versions TestiPhone and iPhone Tester do not support zooming as of this writing, and neither will fake the iPhone user agent.

Fortunately Firefox extension User Agent Switcher lets Firefox users change and add new User Agents. I was able to add the iPhone user agent settings using details from TestiPhone.

1) Install User Agent Switcher Firefox extension

2) Add a new User Agent and supply the following information (Tools > User Agent Switcher > Options)

  • Description: iPhone
  • User Agent: Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)
  • App Name: AppleWebKit/420+ (KHTML, like Gecko)
  • App Version: Version/3.0
  • Platform: Mobile/1A542a Safari/419.3
iPhone User Agent setttings

3) Set the User Agent to your newly created iPhone option

4) Navigate to a website with an iPhone version and enjoy.

Here are some iPhone-compatible places to get you started:

Facebook on the iPhone

Now that the user agent can be easily toggled between iPhone and default, use a web-based testing site like TestiPhone to flip back and forth between the normal and iPhone-optimized version.

iPhone testing with user agent

About the author(s)

Andy started Pain in the Tech in 2005 as a way to share tips and tutorials with friends and family, and evangelize great products and services. By 2008, Pain in the Tech had 7 contributors, thousands of daily page views. Site ownership was transitioned to Matt Thommes in 2008.

Comments

# Yann at 10/27/2007 8:29 pm cst

There is TypePad version for the iphone (http://i.typepad.com) and one for Movable Type too:

http://plugins.movabletype.org/imt/

Quick Link to this comment: http://TTIP.me/c4613

# Randal L. Schwartz at 5/1/2008 5:05 pm cst

You can also "defaults write com.apple.Safari IncludeDebugMenu 1" at the command line in OSX, then stop and restart Safari. This will reveal the "debug" menu, and one of the options is "User Agent -> iPhone", which looks like it has all the right values. Can't wait to try this!

Quick Link to this comment: http://TTIP.me/c4693

# Tr3v at 5/13/2008 2:11 pm cst

Or you can open preferences -> advanced and tick show developer menu if you don't like to mess about in terminal :o)

Quick Link to this comment: http://TTIP.me/c4711

# WebHack at 5/30/2008 3:03 am cst

Hey there,

There's something wrong here. It doesn't work like that.

If you have you settings like this all a UserAgent checker will see is "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)"

And most website use the following script to verify that: [start] if (navigator.userAgent.indexOf('Mobile') <0) { window.location = redirect; if (navigator.userAgent.indexOf('Safari') <0) { window.location = redirect; } } [end]

And this wil result in beging redirected away of being accesed denied.

Instead do some random numbers, as long as is has Mobile/xxy Safari/xx.x where x = a number and y a small alphabetical character. Ohyeah, to prevent language or location deletion also leave away other stuff:

Description: iPhone User Agent: Mobile/12a Safari/23.1 App Name: AppleWebKit/420 App Version: Version/3.0 Platform: iPhone/12a Grizz/23.1

THIS WORKS PERFECT, even after the security updates wherethrue this post didn't work afterall any more.

Spead it out !

- WebHack

Quick Link to this comment: http://TTIP.me/c4696

# Willy at 2/14/2009 11:52 am cst

Can' t you just paste the FULL user-agent string, PLEASE? Sheesh!. This is what I hate about Mac users... you give a step-by-step tutorial for 5 year olds but fail to just paste the real data.

I want to use the FULL user agent string in Mozilla SeaMonkey with the preferences toolbart (hhtp://prefbar.mozdev.org).

I will now have to look elsewhere, as this info cut into bits is of no use for me.

Quick Link to this comment: http://TTIP.me/c4922

# EdwinInTampa at 3/7/2009 8:01 am cst

I don't want optimized pages that in any way reduce capabilities (I'm looking at you Google!).

I don't want to be a second class netizen!

I don't want any of this "separate, but equal" prejudice!

Quick Link to this comment: http://TTIP.me/c4965

# James at 4/7/2009 12:52 pm cst

The best place I know for finding iPhone adapted sites is on the portal MobStart http://mobil.mobstart.dk Look under the category iPhone at the buttom of the site.

James

Quick Link to this comment: http://TTIP.me/c5033

# Easy unlock iphone at 5/5/2009 1:21 am cst

i was trying to unlock my iphone but it didnt work and now it just show me the logo and it just stay like that then I used simpleiphoneunlock.net It seemed to work and now my iphone is unlocked.

Quick Link to this comment: http://TTIP.me/c5055

# Unlock iPhone 3.0 at 6/16/2009 2:44 pm cst

Good work guys! Will this work on the iphone 3g?

Quick Link to this comment: http://TTIP.me/c5166

# Tech World Pro at 7/6/2009 8:51 am cst

@the last commentor - If you read the article, it's about faking an iPhone user agent, this has nothing to do with apps running on an iPhone, it's about simulating an iPhone to test web page compatibility.

Great article btw !!

Quick Link to this comment: http://TTIP.me/c5213

# pav376 at 7/15/2009 12:12 am cst

for those with an iphone (hacked) and want to use the full version of a web page can download UserAgent Faker from cydia

Quick Link to this comment: http://TTIP.me/c5222

# Laurent at 10/7/2009 9:04 am cst

there are already many different user agents for the iPhone, you can find a list here: iPhone user agents

And I usually use a Firefox plug-in called Modify Headers to fake user agents, Im using this one instead of the classical switcher because it allows to inject any kind of http header.

Quick Link to this comment: http://TTIP.me/c5347

# Eric at 2/28/2010 5:08 am cst

You can also fake the User-Agent programmatically with the TcpCatcher tool. Have a look at this

Quick Link to this comment: http://TTIP.me/c5558