1

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

Brian Webster
  • 30,033
  • 48
  • 152
  • 225
matteok
  • 2,189
  • 3
  • 30
  • 54

4 Answers4

1

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/

Ido Green
  • 2,795
  • 1
  • 17
  • 26
  • I would need something that works like this: ìf(iOS_Version >= 3.0) { redirect to other site } Is there a possibility to do that with userAgent??? – matteok Sep 13 '11 at 09:48
1

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.

cbrauchli
  • 1,555
  • 15
  • 25
  • I hope I do not sound stupid but how do I achieve this 3.0 or higher thing. Obviously I can check for specific iOS versions like 4_3_3 but I need to check for 3 or higher. Do I have to check for every single Version of iOS available? – matteok Sep 13 '11 at 12:40
  • @matteok Look at my answer below, it will answer it :) – Akshat Agarwal Oct 15 '15 at 13:57
0

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

Akshat Agarwal
  • 2,837
  • 5
  • 29
  • 49
0

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).

Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111