I'm going to have to respectfully disagree here...to a point.

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







On Sep 15, 2007, at 4:20 PM, rich_wagner wrote:

>
> August,
>
> 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 <[EMAIL PROTECTED]> 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
>>
>> On Sep 15, 2007, at 5:00 AM, August Trometer <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>>> Actually, checking the user-agent string against the device is the
>>> wrong thing to do. What if Apple released an iTablet with Safari
>>> tomorrow? Or what if they license Safari to another device
>>> manufacturer? Then we'd all be back changing our code.
>>
>>> 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
>>
>>> On Sep 14, 2007, at 5:52 PM, Greg McGuinness 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:[EMAIL PROTECTED]
>>
>>>> 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
>>
>>>>> On 9/14/07, rich_wagner <[EMAIL PROTECTED]> wrote:
>>
>>>>> Actually, thinking more about this...it seems like one would want
>>>>> actually expect the platform string to be unique to each device in
>>>>> order to differentiate between them. For example, you would not  
>>>>> want
>>>>> an iPod touch device to try a tel: link.
>>
>>>>> On Sep 14, 1:28 pm, rich_wagner < [EMAIL PROTECTED]>  
>>>>> wrote:
>>>>>> If anyone has an iPod touch, I am curious what the user agent is
>>>>>> and
>>>>>> whether "iPhone" appears in the platform string or whether it is
>>>>>> specific to "iPod touch". My hunch is that they'll maintain
>>>>>> 'iPhone"
>>>>>> for consistency and since the Mobile Safari browser will surely  
>>>>>> be
>>>>>> identical for both devices.
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to