user1237393
user1237393

Reputation: 157

How to detect IPad/IPhone on IOS15 in Javascript

In IOS I've now the following UserAgent:

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

on Safari in my PC I've the following:

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

but I need to detect if my Script runs on IPad or IPhone cause I need to install the MobileDragDrop Polyfill (https://github.com/timruffles/mobile-drag-drop)

All the answers here on StackOverflow about this, are prior to IOS 15, were the navigator property still contained "IPad" or "IPhone"

Upvotes: 0

Views: 2026

Answers (1)

user1237393
user1237393

Reputation: 157

after more research, I found this might work:

navigator.maxTouchPoints && navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome')

but maybe there is a better solution.

Upvotes: 5

Related Questions