IPhone: Detect if iPhone entering application is an original iPhone
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.Us开发者_StackOverflow社区erAgent.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?
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
精彩评论