The iPod Touch user agent string is similar to the iPhone except:- it says "iPod" instead of "iPhone"- AppleWebKit is 420.1 rather than 420+- "3A100a" Safari rather than "1C28 Safari" on the iPhone.
I just posted this at: and have pictures of the new Developer Console at: http://www.iphoneapps.com/2007/09/ipod-touch-developer-debug-console.asp
Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML,
like Gecko) Version/3.0 Mobile/3A100a Safari/419.3
Sorry about the triple post, it was a problem I had with edge.
On Sep 14, 5:52 pm, Greg McGuinness <greg...@mac.com> wrote:
> > The iPod Touch user agent string is similar to the iPhone except:
> > - it says "iPod" instead of "iPhone"
> > - AppleWebKit is 420.1 rather than 420+
> > - "3A100a" Safari rather than "1C28 Safari" on the iPhone.
>
> if ((navigator.userAgent.indexOf('iPhone') != -1) ||
> (navigator.userAgent.indexOf('iPod') != -1)) {
> document.location = "iphonerevu.htm";
>
> }
>
> I just posted this at:http://groups.google.com/group/iphonewebdev/browse_thread/thread/
> e12db4b239e6319d/db564932bfa220a6#db564932bfa220a6
>
> and have pictures of the new Developer Console at:
>
> http://www.iphoneapps.com/2007/09/ipod-touch-developer-debug-console.asp
>
> Greg McGuinness
> mailto:greg...@mac.com
>
> On Sep 14, 2007, at 5:27 PM, Dennis Baldwin wrote:
>
> > I second that notion. I would love to know as well. For my iPhone
> > it looks like the following:
>
> > Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+
> > (KHTML, like Gecko) Version/3.0 Mobile/1C28 Safari/419.3
>
> > I'm wondering if the touch will have the "Mobile" part of the user
> > agent string or what the differentiation will be. If you do have a
> > touch feel free to go to:
>
> >http://iphone.ublip.com/user_agent.php
>
> > and post your results here.
>
> > Thanks,
> > Dennis
>
Instead, look for the words "Mobile" and "Safari." Apple has said that
these will always be in the Safari user-agent string for mobile devices.
if ((navigator.userAgent.indexOf('Mobile') != -1 &&
(navigator.userAgent.indexOf('Safari') != -1 {
// do stuff here
}
-- August
-=Randy
Just to second what Randy said...
Agreed on the general rule of thumb of using object detection and
avoiding user agent detection for Web sites. However, if you are
developing an application specifically for iPhone/iPod, then user
agent detection is a valid way to go. Plus, since an iPhone app is
written for a particular viewport (and might rely on iPhone service
integration), then searching for "iPhone" (and/or "iPod") is preferred
over "Mobile" and "Safari". After all, they could release a iWidePod
that had completely different viewport dimensions.
- Rich
On Sep 15, 3:10 pm, Randy Walker <cleverda...@gmail.com> wrote:
> Yes, Apple could release a new device tomorrow. This device could
> also have Mobile Safari. It could also be yet a different version of
> Safari to take advantage of whatever hardware capabilities this "new"
> device may or may not have in common with iPod touch or existing
> iPhones. I would think checking for just 'mobile' and 'safari' will
> cause you many more headaches than checking for those AND the device
> name as well. I've seen more than one article stating that Phone &
> iPod touch already have dif versions (builds) of safari, even though
> they are both called mobile. Who knows if they will ever be exactly
> the same?
>
> -=Randy
>
> >> mailto:greg...@mac.com
>
> >> On Sep 14, 2007, at 5:27 PM, Dennis Baldwin wrote:
>
> >>> I second that notion. I would love to know as well. For my iPhone
> >>> it looks like the following:
>
> >>> Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+
> >>> (KHTML, like Gecko) Version/3.0 Mobile/1C28 Safari/419.3
>
> >>> I'm wondering if the touch will have the "Mobile" part of the user
> >>> agent string or what the differentiation will be. If you do have a
> >>> touch feel free to go to:
>
> >>>http://iphone.ublip.com/user_agent.php
>
> >>> and post your results here.
>
> >>> Thanks,
> >>> Dennis
>
It simply comes down to what you're trying to test for.
If you're looking for an instance of Mobile Safari, regardless of
device, then using my method is the best way. In fact, I think in most
cases, this _should_ be what you're testing for, as Apple is most
likely to keep various versions of Safari in lock-step across devices.
Sure, they might have different build numbers, but they should be,
capability-wise, so similar you won't know the difference.
If you want to know the width of the device, for example, that's a
completely separate test. To test for the width of the viewport (i.e.
window.innerWidth) is much better than to test for the name of a
device. It's highly likely that a new iPhone might have a higher
resolution and, therefore, a different viewport width. The product
name, however, will stay the same. Testing for the string "iPhone"
doesn't tell you anything except the name of the device.
The only reason I can see for testing against device name is to
determine if it can do something in particular (which is problematic
as those capabilities can and will change while the device name will
not). Using the tel: links for phone numbers obviously won't work on
an iPod touch, so testing for "iPod" is a decent solution here. (I
haven't tried it on the iPod touch, but I suspect Apple filters those
links out. If they don't, they should.)
Here's my point: if you're building a web app for the iPhone, you're
really not developing it for "the iPhone." In actuality, you're
developing it for Mobile Safari which Apple is clearly willing to put
on multiple devices.
August
-=Randy