3

I want to detect that my JS code in a webpage is running in Safari on iOS 11, which supports some new features.

I can do something like

if (window.navigator.userAgent.includes('OS 11_0')) {
    // iOS 11
}

but I believe this is considered unreliable.

Is there some feature or a hack that works only on iOS 11 and not on other OS and can be used to detect that version without inspecting the userAgent?

Update: I am talking about getUserMedia so I am not sure if ther is a way to test it presence without triggering the microphone permission request.

7
  • This is a duplicate of many questions, please search first. And you can't do this reliably. Commented Sep 11, 2017 at 3:47
  • @JaromandaX so what is this feature that can be tested? e.g. if ('blah blah' in window) { // then } Commented Sep 11, 2017 at 3:51
  • @RobG I'm not asking how to detect any OS, I'm only asking about specifically this version of iOS on this particular browser. For example questions about detecting IE11 are irrelevant to me. Commented Sep 11, 2017 at 3:52
  • @JaromandaX very useful advice, thanks. But I'm looking for someone who has tried detecting iOS 11 to share their experience. Commented Sep 11, 2017 at 3:55
  • "which supports some new features" - Can't you test for those features? Commented Sep 11, 2017 at 4:03

1 Answer 1

3

Check out this solution, and then you could do something like this:

ver = iOSversion();

if (ver[0]==11) {
    // do something
}

The shared snippet can also be used to detect any specific iOS version, >iOS 2.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.