|
@@ -99,4 +99,34 @@ export class Utils
|
99
|
99
|
{
|
100
|
100
|
return computeResolution(resolution, aspectRatio);
|
101
|
101
|
}
|
|
102
|
+
|
|
103
|
+ /**
|
|
104
|
+ * Returns a string containing platform brand information
|
|
105
|
+ * @returns platform brand information
|
|
106
|
+ */
|
|
107
|
+ static platformString(): string
|
|
108
|
+ {
|
|
109
|
+ return ((navigator: any): string =>
|
|
110
|
+ typeof navigator.userAgentData === 'object' ? // prefer the NavigatorUAData interface
|
|
111
|
+ navigator.userAgentData.platform : // use only low entropy data
|
|
112
|
+ navigator.platform // navigator.platform is deprecated
|
|
113
|
+ )(navigator);
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ /**
|
|
117
|
+ * Checks if we're on iOS
|
|
118
|
+ * @returns true if we're on iOS
|
|
119
|
+ */
|
|
120
|
+ static isIOS(): boolean
|
|
121
|
+ {
|
|
122
|
+ const platform = Utils.platformString();
|
|
123
|
+
|
|
124
|
+ if(/(iOS|iPhone|iPad|iPod)/i.test(platform))
|
|
125
|
+ return true;
|
|
126
|
+
|
|
127
|
+ if(/Mac/i.test(platform) && navigator.maxTouchPoints !== undefined) // iPad OS 13+
|
|
128
|
+ return navigator.maxTouchPoints > 2;
|
|
129
|
+
|
|
130
|
+ return false;
|
|
131
|
+ }
|
102
|
132
|
}
|