Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_constants.IS_IOS not working #2956

Open
nathnolt opened this issue Apr 18, 2024 · 0 comments
Open

_constants.IS_IOS not working #2956

nathnolt opened this issue Apr 18, 2024 · 0 comments

Comments

@nathnolt
Copy link

I'm using an IPAD 9th generation, on OS 17.2,

The current detection for IOS and IPAD roughtly looks like this:

var UA = window.navigator.userAgent.toLowerCase()
var IS_IOS = /ipad|iphone|ipod/i.test(UA) && !window.MSStream;
var IS_IPAD = /ipad/i.test(UA) && !window.MSStream;

My device says that it's false.

Lookin on the internet resolves to stackoverflow ( https://stackoverflow.com/questions/9038625/detect-if-device-is-ios )
They propose the following solution:

function iOS() {
  return [
    'iPad Simulator',
    'iPhone Simulator',
    'iPod Simulator',
    'iPad',
    'iPhone',
    'iPod'
  ].includes(navigator.platform)
  // iPad on iOS 13 detection
  || (navigator.userAgent.includes("Mac") && "ontouchend" in document)
}

This solution does appear to work (on the device I own). And as it has a lot of upvotes, I'm going to assume that it must work quite well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant