The user agent of Safari on iPadOS beta is at this point exactly the same as Safari on macOS. Is there any other way to tell an iPad from a Mac?
iPad running
I would not generally recommend this, and I haven't tested it much (using something similar in production since September 2019), but one way could be to detect the existence of TouchEvent
on the client side, and match it with the state of the user agent to account for older iOS versions of iPad:s. YMMV. Likely not very future safe.
function isIpad() {
const ua = window.navigator.userAgent;
if (ua.indexOf('iPad') > -1) {
return true;
}
if (ua.indexOf('Macintosh') > -1) {
try {
document.createEvent("TouchEvent");
return true;
} catch (e) {}
}
return false;
}