mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 07:58:45 +03:00
https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
This commit is contained in:
parent
03b0a5afa6
commit
5ea9f0ec16
@ -58,7 +58,9 @@
|
|||||||
SONY = 'Sony',
|
SONY = 'Sony',
|
||||||
XIAOMI = 'Xiaomi',
|
XIAOMI = 'Xiaomi',
|
||||||
ZEBRA = 'Zebra',
|
ZEBRA = 'Zebra',
|
||||||
FACEBOOK = 'Facebook';
|
FACEBOOK = 'Facebook',
|
||||||
|
CHROMIUM_OS = 'Chromium OS',
|
||||||
|
MAC_OS = 'Mac OS';
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
// Helper
|
// Helper
|
||||||
@ -721,7 +723,7 @@
|
|||||||
], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
|
], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
|
||||||
/(mac os x) ?([\w\. ]*)/i,
|
/(mac os x) ?([\w\. ]*)/i,
|
||||||
/(macintosh|mac_powerpc\b)(?!.+haiku)/i // Mac OS
|
/(macintosh|mac_powerpc\b)(?!.+haiku)/i // Mac OS
|
||||||
], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [
|
], [[NAME, MAC_OS], [VERSION, /_/g, '.']], [
|
||||||
|
|
||||||
// Mobile OSes
|
// Mobile OSes
|
||||||
/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS
|
/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS
|
||||||
@ -745,7 +747,7 @@
|
|||||||
/crkey\/([\d\.]+)/i // Google Chromecast
|
/crkey\/([\d\.]+)/i // Google Chromecast
|
||||||
], [VERSION, [NAME, CHROME+'cast']], [
|
], [VERSION, [NAME, CHROME+'cast']], [
|
||||||
/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i // Chromium OS
|
/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i // Chromium OS
|
||||||
], [[NAME, 'Chromium OS'], VERSION],[
|
], [[NAME, CHROMIUM_OS], VERSION],[
|
||||||
|
|
||||||
// Smart TVs
|
// Smart TVs
|
||||||
/panasonic;(viera)/i, // Panasonic Viera
|
/panasonic;(viera)/i, // Panasonic Viera
|
||||||
@ -887,6 +889,11 @@
|
|||||||
if (!_device[TYPE] && _uach && _uach.mobile) {
|
if (!_device[TYPE] && _uach && _uach.mobile) {
|
||||||
_device[TYPE] = MOBILE;
|
_device[TYPE] = MOBILE;
|
||||||
}
|
}
|
||||||
|
// iPadOS-specific detection: identified as Mac, but has some iOS-only properties
|
||||||
|
if (_device[MODEL] == 'Macintosh' && _navigator && typeof _navigator.standalone !== UNDEF_TYPE && _navigator.maxTouchPoints && _navigator.maxTouchPoints > 2) {
|
||||||
|
_device[MODEL] = 'iPad';
|
||||||
|
_device[TYPE] = TABLET;
|
||||||
|
}
|
||||||
return _device;
|
return _device;
|
||||||
};
|
};
|
||||||
this.getEngine = function () {
|
this.getEngine = function () {
|
||||||
@ -899,8 +906,8 @@
|
|||||||
rgxMapper.call(_os, _ua, _rgxmap.os);
|
rgxMapper.call(_os, _ua, _rgxmap.os);
|
||||||
if (!_os[NAME] && _uach && _uach.platform != 'Unknown') {
|
if (!_os[NAME] && _uach && _uach.platform != 'Unknown') {
|
||||||
_os[NAME] = _uach.platform
|
_os[NAME] = _uach.platform
|
||||||
.replace(/chrome os/i, 'Chromium OS')
|
.replace(/chrome os/i, CHROMIUM_OS)
|
||||||
.replace(/macos/i, 'Mac OS'); // backward compatibility
|
.replace(/macos/i, MAC_OS); // backward compatibility
|
||||||
}
|
}
|
||||||
return _os;
|
return _os;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user