What is the iOS 5.0 user agent string?
Solution 1
iPhone:
Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3
iPad:
Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3
Solution 2
This site seems to keep a complete list that's still maintained
iPhone, iPod Touch, and iPad from iOS 2.0 - 5.1.1 (to date).
You do need to assemble the full user-agent string out of the information listed in the page's columns.
Solution 3
I found a more complete listing at user agent string. BTW, this site has more than just iOS user agent strings. Also, the home page will "break down" the user agent string of your current browser for you.
Solution 4
fixed my agent string evaluation by scrubbing the string for LOWERCASE "iphone os 5_0" as opposed to "iPhone OS 5_0." now i am properly assigning iOS 5 specific classes to my html, when the uppercase scrub failed.
Solution 5
I use the following to detect different mobile devices, viewport and screen. Works quite well for me, might be helpful to others:
var pixelRatio = window.devicePixelRatio || 1;
var viewport = {
width: window.innerWidth,
height: window.innerHeight
};
var screen = {
width: window.screen.availWidth * pixelRatio,
height: window.screen.availHeight * pixelRatio
};
var iPhone = /iPhone/i.test(navigator.userAgent);
var iPhone4 = (iPhone && pixelRatio == 2);
var iPhone5 = /iPhone OS 5_0/i.test(navigator.userAgent);
var iPad = /iPad/i.test(navigator.userAgent);
var android = /android/i.test(navigator.userAgent);
var webos = /hpwos/i.test(navigator.userAgent);
var iOS = iPhone || iPad;
var mobile = iOS || android || webos;
window.devicePixelRatio
is the ratio between physical pixels and device-independent pixels (dips) on the device.
window.devicePixelRatio
= physical pixels / dips.
More info here.
chown
Python for iOS - Python Interpreter / IDE iOS App I created in my spare time. Python 2.7 for iOS- on the iTunes App Store <> chown -fLR us /base/your/* <> #SOreadytohelp
Updated on March 07, 2020Comments
-
chown about 4 years
What is the iOS 5.0 user agent string?
Here is the iOS 4.0 user agent: What is the iPhone 4 user-agent?
-
Ben over 12 yearsCorrect. From my iPhone: Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3
-
hndcrftd over 12 yearsWell, I, personally would detect more than just iPhone, because in the example above you are not rendering iOS 5 specific code to iPads and iPod touch. What you might also want to think about is the fact that the version will increment at some point. My recommendation would probably be apparent to most - detect an apple mobile device first, i.e. iPad/iPod/iPhone and then, if that's the case, parse out the version of... not the iOS but probably the browser, i.e. in this case Version/5.1 would be the indicator. Once you know the version, you would apply your code on "not lower than" condition.
-
Andrew Steitz over 11 yearsI started with the site referenced here but it did not have the web-kit build number, which is what Google Analytics displays. I found a more complete list at useragentstring.com/pages/Safari.
-
Mauvis Ledford over 11 yearsThanks for the response, but note that this isn't an efficient way and some device versions will be lost. For example I just checked the user agent on my ancient iPad 1 and it says "...iPad; CPU OS 5_1_1...". None of your variables would have caught that. You would need a regex like
var iOS5 = /(iPhone|iPad).*OS 5_.*/i.test(navigator.userAgent);
-
bashan over 9 yearsI compiled a list with VERY big amount of user-agents. Hope it will help: codereye.com/2014/12/list-of-mobile-user-agents.html
-
bashan over 9 yearsThanks @Nate, will do so.
-
Lucas about 6 yearsThe user agent string link is broken. :( I think it should point here now: useragentstring.com/pages/useragentstring.php?name=Safari
-
Andrew Steitz about 6 years@LucasMorgan, thanks for the note! I have fixed it in my answer.