Update ios device detection

This commit is contained in:
Julia Radzhabova 2021-02-12 12:16:16 +03:00
parent 5160969db3
commit e19775972a
3 changed files with 51 additions and 9 deletions

View file

@ -70,9 +70,23 @@ define([
};
function iOSVersion() {
var ua = navigator.userAgent;
var m;
return (m = /(iPad|iPhone|iphone).*?(OS |os |OS\_)(\d+((_|\.)\d)?((_|\.)\d)?)/.exec(ua)) ? parseFloat(m[3]) : 0;
var ua = navigator.userAgent.toLowerCase();
var isAppleDevices = (ua.indexOf("ipad") > -1 || ua.indexOf("iphone") > -1 || ua.indexOf("ipod") > -1);
if (!isAppleDevices && Common.Utils.isSafari && Common.Utils.isMac && (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1))
isAppleDevices = true;
var iosversion = 0;
if (isAppleDevices) {
iosversion = 13;
try
{
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
if (!v) v = (navigator.appVersion).match(/Version\/(\d+).(\d+)/);
iosversion = parseInt(v[1], 10);
}
catch (err) {}
}
return iosversion;
}
return {

View file

@ -70,9 +70,23 @@ define([
};
function iOSVersion() {
var ua = navigator.userAgent;
var m;
return (m = /(iPad|iPhone|iphone).*?(OS |os |OS\_)(\d+((_|\.)\d)?((_|\.)\d)?)/.exec(ua)) ? parseFloat(m[3]) : 0;
var ua = navigator.userAgent.toLowerCase();
var isAppleDevices = (ua.indexOf("ipad") > -1 || ua.indexOf("iphone") > -1 || ua.indexOf("ipod") > -1);
if (!isAppleDevices && Common.Utils.isSafari && Common.Utils.isMac && (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1))
isAppleDevices = true;
var iosversion = 0;
if (isAppleDevices) {
iosversion = 13;
try
{
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
if (!v) v = (navigator.appVersion).match(/Version\/(\d+).(\d+)/);
iosversion = parseInt(v[1], 10);
}
catch (err) {}
}
return iosversion;
}
return {

View file

@ -69,9 +69,23 @@ define([
};
function iOSVersion() {
var ua = navigator.userAgent;
var m;
return (m = /(iPad|iPhone|iphone).*?(OS |os |OS\_)(\d+((_|\.)\d)?((_|\.)\d)?)/.exec(ua)) ? parseFloat(m[3]) : 0;
var ua = navigator.userAgent.toLowerCase();
var isAppleDevices = (ua.indexOf("ipad") > -1 || ua.indexOf("iphone") > -1 || ua.indexOf("ipod") > -1);
if (!isAppleDevices && Common.Utils.isSafari && Common.Utils.isMac && (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1))
isAppleDevices = true;
var iosversion = 0;
if (isAppleDevices) {
iosversion = 13;
try
{
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
if (!v) v = (navigator.appVersion).match(/Version\/(\d+).(\d+)/);
iosversion = parseInt(v[1], 10);
}
catch (err) {}
}
return iosversion;
}
return {