Panup Pong
Panup Pong

Reputation: 1891

How to detect Ipad useragent on safari browser

when I use ipad on chrome the useragent is

Mozila/5.0(iPad; CPU OS 9_3_5 like Mac OS X) AppleWebKit/601.1 (KHTML,like Gecko) CruiOS/57.0.2987.137 Mobile/13G36 ....

but ipad on safari is

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

And MacOS useragent is

Safari: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36

Problem : Since on iPadOS User Agent on Safari is same as on MacOS notebook following https://forums.developer.apple.com/thread/119186

and I this issue of Mobile_Detect php library https://github.com/serbanghita/Mobile-Detect/issues/795

Upvotes: 9

Views: 12803

Answers (1)

John Mc
John Mc

Reputation: 411

To detect iPads, try this:

let isIpad = /Macintosh/i.test(navigator.userAgent) && navigator.maxTouchPoints && navigator.maxTouchPoints > 1;

Upvotes: 15

Related Questions