ua-parser-js icon indicating copy to clipboard operation
ua-parser-js copied to clipboard

iPad Air and iPad Pro - type not correctly identified

Open dann2g opened this issue 7 months ago • 6 comments

Library version v1.0.37

Describe the bug iPad Pro and iPad Air user agents from Chrome Dev Tools are not recognized as tablets. Mentioning Chrome Dev Tools here as I can't rule out Chrome using incorrect user agents.

To Reproduce Steps to reproduce the behavior:

  1. Open Chrome Dev Tools --> Device Toolbar
  2. Select iPad Air or iPad Pro from list
  3. Visit webpage that uses ua-parser-js
  4. device is returned as { vendor: 'Apple', model: 'Macintosh', type: undefined }

Alternatively use one of these user agents which is what my Chrome (Version 119.0.6045.124) is using:

  • iPad Air - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15
  • iPad Pro - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15

Expected behavior device returned as { vendor: 'Apple', model: 'iPad', type: 'tablet' }

dann2g avatar Nov 16 '23 16:11 dann2g

If you use getOS function through the ipads, what is returned inside { name } of both of them?

rickson-simoes avatar Nov 21 '23 14:11 rickson-simoes

Hi @rickson-simoes, in both cases I get {name: 'Mac OS', version: '10.15.7'} with the getOS function. I guess this should be iOS instead. Selecting "IPad Mini" in the browser returns {name: 'iOS', version: '16.6'} for example.

FelixK-Witt avatar Nov 27 '23 09:11 FelixK-Witt

I am facing same issue, it cannot detect Ipad with latest iOS 17, i am getting - { vendor: 'Apple', model: 'Macintosh', type: undefined }. Apple updated userAgent for iPad - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1.1 Safari/604.1 - this from real iPad Safari using latest iOS 17. So there is no iPad anymore in useragent. Has anyone found how to detect iPad ?

jemil-neuffer avatar Nov 27 '23 12:11 jemil-neuffer

Since Apple froze its user agent in version 10.15.7, we haven't yet find a reliable solution that can be derived from only the user agent data (as in the Chrome Dev Tools case). However, if we are using a real browser in iPad we can try to do an additional check for iPad-specific browser features:

const uap = new UAParser();
const device1 = uap.getDevice();
const device2 = uap.getDevice().withFeatureCheck();

console.log(device1); // { vendor : "Apple", model : "Macintosh", type : undefined }
console.log(device2); // { vendor : "Apple", model : "iPad", type : "tablet" }
  • https://docs.uaparser.js.org/v2/api/ua-parser-js/idata/with-feature-check.html

faisalman avatar Nov 30 '23 03:11 faisalman

@faisalman Thanks for the workaround. Small question: Does calling .withFeatureCheck() also correct browser.name? Namely, update it from Safari to Mobile Safari?

aradalvand avatar Dec 08 '23 04:12 aradalvand

Hi @faisalman what are valid values for model when using uap.getDevice().withFeatureCheck() ? will it detect iPhone ?

kofifus avatar May 03 '24 01:05 kofifus