1 |
|
2 | export const getOperatingSystem = () => {
|
3 | var _a, _b;
|
4 | const userAgent = window.navigator.userAgent;
|
5 | const platform =
|
6 |
|
7 | ((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgentData) === null || _b === void 0 ? void 0 : _b.platform) || window.navigator.platform;
|
8 | const macosPlatforms = ["macOS", "Macintosh", "MacIntel", "MacPPC", "Mac68K"];
|
9 | const windowsPlatforms = ["Win32", "Win64", "Windows", "WinCE"];
|
10 | const iosPlatforms = ["iPhone", "iPad", "iPod"];
|
11 | if (macosPlatforms.indexOf(platform) !== -1) {
|
12 | return "Mac OS";
|
13 | }
|
14 | else if (iosPlatforms.indexOf(platform) !== -1) {
|
15 | return "iOS";
|
16 | }
|
17 | else if (windowsPlatforms.indexOf(platform) !== -1) {
|
18 | return "Windows";
|
19 | }
|
20 | else if (/Android/.test(userAgent)) {
|
21 | return "Android";
|
22 | }
|
23 | else if (/Linux/.test(platform)) {
|
24 | return "Linux";
|
25 | }
|
26 | return null;
|
27 | };
|