Check if iOS version is 3.0 or higher with PHP or Javascript

后端 未结 4 1124
清酒与你
清酒与你 2021-01-23 22:59

I need to check if an iOS device visiting my Website has iOS 3.0 or higher installed. Can I do that?

4条回答
  •  长发绾君心
    2021-01-24 00:01

    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.

提交回复
热议问题