bestiejs / platform.js

A platform detection library.
https://mths.be/platform
MIT License
3.22k stars 408 forks source link

Support iPadOS #175

Closed shayc closed 3 years ago

shayc commented 5 years ago

iPadOS is being detected as macOS, this was done by Apple to make Safari behave more like a desktop version.

So the only way that I know of to detect iPadOS is by checking for maxTouchPoints since Macs don't have touch screens (as of yet).

 if (navigator.userAgent.match(/Mac/) && navigator.maxTouchPoints && navigator.maxTouchPoints > 2) {
     ...must be iPad OS...

Would you consider this a viable solution?

r10s commented 4 years ago

thanks for the hint, came over this while figuring out the same thing for delta chat (https://github.com/deltachat/deltachat-pages/issues/338) - seems to do the job :)

however, wondering, where the navigator.maxTouchPoints > 2 comes from, navigator.maxTouchPoints > 1 would sound more logical to me.

shayc commented 4 years ago

however, wondering, where the navigator.maxTouchPoints > 2 comes from, navigator.maxTouchPoints > 1 would sound more logical to me.

I agree, I found the solution online, maybe these days people have a more intuitive one. All I remember is that it was hard to find something that works.

I’m glad you found it useful though, half of my comments on GitHub are for people to find them in the future!

r10s commented 4 years ago

half of my comments on GitHub are for people to find them in the future!

yeah! please keep on commenting :)