added isAppleMobileBrowser util

This commit is contained in:
Kyle Spearrin 2019-09-06 09:06:01 -04:00
parent b74ee7b3ee
commit cc614e68d9
1 changed files with 6 additions and 0 deletions

View File

@ -11,6 +11,7 @@ export class Utils {
static isNode = false; static isNode = false;
static isBrowser = true; static isBrowser = true;
static isMobileBrowser = false; static isMobileBrowser = false;
static isAppleMobileBrowser = false;
static global: any = null; static global: any = null;
static tldEndingRegex = /.*\.(com|net|org|edu|uk|gov|ca|de|jp|fr|au|ru|ch|io|es|us|co|xyz|info|ly|mil)$/; static tldEndingRegex = /.*\.(com|net|org|edu|uk|gov|ca|de|jp|fr|au|ru|ch|io|es|us|co|xyz|info|ly|mil)$/;
@ -25,6 +26,7 @@ export class Utils {
Utils.isBrowser = typeof window !== 'undefined'; Utils.isBrowser = typeof window !== 'undefined';
Utils.isNativeScript = !Utils.isNode && !Utils.isBrowser; Utils.isNativeScript = !Utils.isNode && !Utils.isBrowser;
Utils.isMobileBrowser = Utils.isBrowser && this.isMobile(window); Utils.isMobileBrowser = Utils.isBrowser && this.isMobile(window);
Utils.isAppleMobileBrowser = Utils.isBrowser && this.isAppleMobile(window);
Utils.global = Utils.isNativeScript ? global : (Utils.isNode && !Utils.isBrowser ? global : window); Utils.global = Utils.isNativeScript ? global : (Utils.isNode && !Utils.isBrowser ? global : window);
} }
@ -257,6 +259,10 @@ export class Utils {
return mobile || win.navigator.userAgent.match(/iPad/i) != null; return mobile || win.navigator.userAgent.match(/iPad/i) != null;
} }
private static isAppleMobile(win: Window) {
return win.navigator.userAgent.match(/iPhone/i) != null || win.navigator.userAgent.match(/iPad/i) != null;
}
private static getUrl(uriString: string): URL { private static getUrl(uriString: string): URL {
if (uriString == null) { if (uriString == null) {
return null; return null;