What is the user agent of an iPhone that does not have 4.0+?
Can开发者_JAVA百科 someone give examples? I know that iPhone 4.2.1 has "4_2" inside the user agent.
What about other models? Can someone help?
Google is your friend. It's easy to find a definitive list of Safari user agent strings, of which many are Mobile Safari on iPhone. An example pre-iOS 4.0 string is:
Mozilla/5.0 (iPhone; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10
Note the strings "iPhone" and "CPU OS 3_2 like Mac OS X" which tell you it's an iPhone running iOS 3.2.
You are probably really looking for the user agent string of the browser people use on the iPhone (not the phone itself), which is normally Mobile Safari, in combination with the device (iPhone, iPad, etc.) Remember that a user could install other browsers if they wish, and that iOS runs on more devices than just the iPhone (two others, at the moment, and who knows what will happen in the future.) This is a long way of saying, be careful how you do and what you do with your user agent sniffing.
精彩评论