Free tech support / small logo


How can I auto-detect that someone's on an Apple iPad?

I'm working on my Web site and now that the Apple iPad is out, I'd like to customize my greeting for people using that device. How can I auto-detect that they're on an iPad?


Dave's Answer:

There are a ton of tools to help you with this particular task, and I've written about it before too (see How to detect an iPhone web browser). The basic idea is that every Web browser on every hardware platform sends what's called a USER_AGENT identifier. Almost all of the time they're accurate, but some test browsers have the ability to pretend they're something else (known in the biz as "spoofing", actually).

On my Mac OS X system, for example, when I am hitting Web pages within Google's Chrome browser, here's what is sent to the Web server for each and every transaction I do, whether an HTML page, PHP search result or even ask for a photo or other image:

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.347.0 Safari/533.2

You can check your Web browser too. Just pop over to Microsystools and find out.

Now, the question of the moment is, what string does it show when you're on an Apple iPad?

Here's the answer:

Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version /4.0.4 Mobile/7B367 Safari/531.21.10

Pretty ugly, really, but the key thing to notice is that the first word within parens identifies the hardware platform. If you're writing code of some sort, simply grab the USER_AGENT string, then check that first word.

Oh, if you're on an iPhone and you go to the same page, here's the USER_AGENT you are sending on each query:

Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version /4.0 Mobile/7E18 Safari/528.16

Good luck!

Looking for iPad help? Good news; you've found it!









Subscribe!
Never miss another Q&A article! Click to subscribe: Add to Google Reader Add to My Yahoo! Subscribe in NewsGator RDF XML
Comments

Thanks for this post! Very useful.

I created a small tutorial that shows how to detect the ipad browser and redirect to an appropriate directory.

http://cardonadesigns.com/wordpress/2010/04/04/using-php-to-detect-the-ipad-user-agent/

Posted by: Carlos Cardona at April 5, 2010 9:49 PM

I also need to redirect iphone users to a html version of the site since flash isn’t read by apple iphones!
but I need a HTML code to do that since my index page is in html and all the other php etc etc seem not working (
please Help!

Posted by: sam at June 1, 2010 1:39 AM

I have something to say, now that you mention it, but ...
Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you for all your efforts on this Web site by buying you a cup of coffee!

I do have a comment, now that you mention it!











Remember personal info?


Please note that I will never send you any unsolicited email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









Recent Entries


Search
I Need Help!
Need Help? Ask Dave Taylor!


© 2002 - 2012 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.