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

iOS 13 detection as MacOS #17

Closed
fadykstas opened this issue Nov 25, 2019 · 1 comment
Closed

iOS 13 detection as MacOS #17

fadykstas opened this issue Nov 25, 2019 · 1 comment

Comments

@fadykstas
Copy link

On iOS 13 window.navigator.userAgent in Safari on iOS 13 is same as on MacOS. Something like this:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15

the reason is because "Request Desktop Website" parameter is now enabled by default, so instead of os-ios we get os-mac on iOS 13

Indeed, while option change in Settings may be a good solution for the user, any developer can't rely on that. It is as weird as to ask the user to not to use dark mode cause your app doesn't support it instead of opt-out of it using plist.

Proposal is to add additional validation for os-mac:

const isIOS = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1

real macs have no multi-touch support, this solution is ideal to detect iOS 13 devices which are the only multi-touch "MacIntel" devices in existence

@srfrnk
Copy link
Owner

srfrnk commented Dec 12, 2019

Introducing a reference to navigator within parseUserAgent would break the idempotent design for the module and I would prefer not to do that.

To continue the current design I suggest to add the required information as an option to parseUserAgent the same as the user agent is sent.

To keep things as generic as possible I would add two distinct new options:

  1. platform [optional]: can be initialized from navigator.platform
  2. maxTouchPoints [optional]: can be initialized from navigator.maxTouchPoints

That would change usage from:

var deviceInfo=window.uaDeviceDetector.parseUserAgent({
      userAgent: navigator.userAgent,
});

To:

var deviceInfo=window.uaDeviceDetector.parseUserAgent({
      userAgent: navigator.userAgent,
      platform: navigator.platform,
      maxTouchPoints: navigator.maxTouchPoints
});

Would that be good for you?

srfrnk added a commit that referenced this issue Dec 12, 2019
@srfrnk srfrnk closed this as completed Aug 1, 2020
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

2 participants