Search code examples
iosipaduser-agentios13ipados

Distinguish between iPad and mac on iPad with iPadOs


In iOS 13 apple changed the user-agent that iPad uses.

Instead of (for example)

Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10

it become (for example)

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

My question is how can we distinguish between iPad and mac now?


Solution

  • The condition I used to detect IpadOS:

    ua.toLowerCase().indexOf('macintosh') > -1 && navigator.maxTouchPoints && navigator.maxTouchPoints > 2