I need to check if an iOS device visiting my Website has iOS 3.0 or higher installed. Can I do that?
Bit of an older question, but I believe none of the answers currently given answer the question appropriately.
If you want to do something like
if(iOS_version > 3){
// Open something
}
Then I believe you are looking for
if(/(iPhone|iPad|iPod)\sOS\s3/.test(navigator.userAgent)) {
// use apple maps
}
Where s3 is looking for iOS3. Change s3 to s9 to check for iOS9
You can use the user-agent
which is send with the HTTP-request. This can then be processed by PHP.
See this tutorial (note that this targets the iPad. But the iPhone should have something similar).
If you wish to check what browser/mobile device is accessing you site - then the answer is that you can use read the userAgent string and search for OS and the number. For example:
Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
and another useful online tool to check your browser UA is: http://whatsmyuseragent.com/
Yes you can. Either PHP or Javascript will do the trick. iOS devices report their iOS version in their user-agent
string. Here are the Apple docs: Using the Safari User Agent String. Some example user-agent
strings might look like:
Mozilla/5.0 (iPhone; U; CPU iOS 2_0 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/XXXXX Safari/525.20
Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.05 Mobile/8A293 Safari/6531.22.7
Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5
From there it's easy to see which version of iOS is being run.