Detect iOS and iPadOS in Frontend Code: User Agent, MacIntel and Touch
Introduction
Frontend projects sometimes need to identify the device type—for example, whether the visitor is using iOS or Android.
Why User-Agent Checks Miss iPadOS
Traditionally, an iOS check might inspect only the browser’s user agent:
| |
This does not reliably identify newer iPads. Starting with iPadOS 13, an iPad can report its platform as MacIntel, causing it to be mistaken for a Mac.
Use a combined check instead:
| |
Although iPadOS 13 and later can identify the device as MacIntel, an iPad still supports multitouch. Checking navigator.maxTouchPoints > 1 distinguishes it from a typical Mac.