0

I need to detect if an iPhone entering my application is an original iPhone (one of the first iPhones to be sold)

I know that this line will detect iPhones:

if (Request.UserAgent.ToUpper().Contains("IPHONE")) 
{
   //Do something
}

But I want to make sure that I get the correct one. I was thinking about something like this:

if (Request.UserAgent.ToUpper().Contains("IPHONE")) 
{
   if (double.Parse(Request.Browser.Version) > 1)
   {
       //Do Something
   }
}

But I am worried that there could be other iPhones that are newer and are version 1.

Is this code correct for finding very old iPhones, or is there a better way?

Cœur
  • 32,421
  • 21
  • 173
  • 232
Stanley Cup Phil
  • 9,502
  • 27
  • 86
  • 144
  • What is your requirement? Is the application calculation-intensive? If it is, I would perform a benchmark test, like http://stackoverflow.com/questions/3093899/detect-the-specific-iphone-ipod-touch-model-in-javascript – Evan Mulawski Jul 14 '11 at 14:35
  • The application is for with facebook connect. Apparently the new updates with the facebook javascript SDK cause redirect errors with original iPhones. I have a workaround set up, I just need to be able to send the correct phones there – Stanley Cup Phil Jul 14 '11 at 14:39

1 Answers1

1

The user agent strings for iPhone only ever contain an OS version. For example:

Mozilla/5.0 (iPhone; U; CPU *iPhone OS 4_1* like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7

Here is a website with a comprehensive list.
http://www.useragentstring.com/

I think that the trouble you may run into is that the browser version, or even the OS version may not indicate the actual generation of the phone itself. Thankfully, there is a list on the wiki about all of the versions and their applications so you can easily figure out what will work best.

http://en.wikipedia.org/wiki/IOS_version_history

A.R.
  • 14,305
  • 17
  • 71
  • 121