How to detect iPad and iPad OS version in iOS 13 and Up?
ios, ios13, ipad, ipados13, javascript
Solution
I was able to get iPad detection working by checking for `navigator.maxTouchPoints` as well as `navigator.platform`. It's not perfect (as discussed in the comments below) but it's the best solution I've come across so far so I wanted to share.
const iPad = (userAgent.match(/(iPad)/) /* iOS pre 13 */ ||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1) /* iPad OS 13 */);
Problem
I can detect iOS 13 on iPhone but in iPad OS 13 `navigator.platform` comes as MacIntel. So it is not possible to get iPad identified using below code, but it works perfectly on iPhone. ``` if (/iP(hone|od|ad)/.test(navigator.platform)) { var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); var version = [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)]; return version; } ``` When we request for mobile website using the browser on iPad `navigator.platform` returns as iPad and works perfectly. Can anyone suggest a way to identify iPad running on iOS 13 and up using Javascript?