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

is.tablet() returns false on iPad #306

Open
JamesS-M opened this issue Jan 28, 2020 · 4 comments
Open

is.tablet() returns false on iPad #306

JamesS-M opened this issue Jan 28, 2020 · 4 comments

Comments

@JamesS-M
Copy link

JamesS-M commented Jan 28, 2020

  get isMobile() {
    alert(`is mobile: ${is.mobile()}`);
    return is.mobile();
  }

  get isTablet() {
    alert(`is tablet: ${is.tablet()}`);
    return is.tablet();
  }

isMobile returns the correct value, but isTablet returns false on Safari and Firefox.

This is the regex match which appears to be returning unexpected behavior.

is.js/is.js

Lines 678 to 681 in 5629495

is.ipad = function(range) {
var match = userAgent.match(/ipad.+?os (\d+)/);
return match !== null && compareVersion(match[1], range);
};

These are my results when logging out userAgent on iPad.

Safari: mozilla/5.0 (macintosh; intel mac os x 10_15) applewebkit/605.1.15 (khtml, like gecko) version/12.0.4 safari/605.1.15

Firefox: mozilla/5.0. (macintosh; intel mac os x 10.15) applewebkit/6051.15 (khtml, like gecko) fxios/22.0 safari/605.1.15

Chrome: mozilla/5.0 (ipad; cpu os 13_3 like max os x) applewebkit/650.1.15 (khtml, like gecko) crios/79.0.3945.73 mobile/15e148 safari/604.1

@Mark5labs
Copy link

Mark5labs commented Apr 21, 2020

iPad with iPad OS13 shows fake User Agent.
image
This is what in iPad's Safari Settings called "Request Desktop Website" and this is ON by default.
image
If I change it to OFF I see correct info:
image
I needed to show notification only on desktop safari and I used is.not.touchDevice() && is.safari() to detect if it is not iPad. Only this helped me.

@evdama
Copy link

evdama commented Mar 18, 2022

I've migrated the entire repo to ES6 and merged/fixed a few things along the way... can you try again with https://github.com/evdama/is-it-check as I've added a fix/feature for iOS13 today evdama@06f7d54

@silasabbott
Copy link

As of now, on an iPad Pro (12.9-inch) (4th gen) running iPadOS 15.4, here’s what returns:

is.js

is.tablet() // false
is.ios()    // false
is.safari() // true
is.ipad()   // false
is.mobile() // false

is-it-check

is.tablet() // true
is.ios()    // true
is.safari() // true
is.ipad()   // true
is.mobile() // true

🎉

@evdama
Copy link

evdama commented Apr 9, 2022

excellent, so I consider this fixed in is-it-check 👍
did you test with is-it-check v1.0.11, which is the current version I pushed to npm?

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

4 participants