faisalman / ua-parser-js

"Unmask Your Traffic" - UAParser.js: The Essential Web Development Tool for User-Agent Detection
https://uaparser.dev/
GNU Affero General Public License v3.0
9.28k stars 1.2k forks source link

iPad Air and iPad Pro - type not correctly identified #690

Open dann2g opened 1 year ago

dann2g commented 1 year ago

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:

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

rickson-simoes commented 1 year ago

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

FelixK-Witt commented 12 months ago

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.

jemil-neuffer commented 12 months ago

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 ?

faisalman commented 11 months ago

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" }
aradalvand commented 11 months ago

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

kofifus commented 6 months ago

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

xiaoyang678 commented 4 months ago

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:由于Apple在10.15.7版本中冻结了其用户代理,我们还没有找到一个可靠的解决方案,可以只从用户代理数据(如Chrome Dev Tools案例)中导出。但是,如果我们在iPad中使用真实的浏览器,我们可以尝试对iPad特定的浏览器功能进行额外检查:

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.dev/api/ua-parser-js/idata/with-feature-check.html