workadventure/front/src/WebRtc/DeviceUtils.ts
David Négrier ab0f5e9837 Stopping sending literal errors
Errors now must be of "Error" type.
Rule added in eslint.
2022-01-06 10:52:06 +01:00

30 lines
898 B
TypeScript

export function isIOS(): boolean {
return (
["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"].includes(
navigator.platform
) ||
// iPad on iOS 13 detection
(navigator.userAgent.includes("Mac") && "ontouchend" in document)
);
}
export enum NavigatorType {
firefox = 1,
chrome,
safari,
}
export function getNavigatorType(): NavigatorType {
if (window.navigator.userAgent.includes("Firefox")) {
return NavigatorType.firefox;
} else if (window.navigator.userAgent.includes("Chrome")) {
return NavigatorType.chrome;
} else if (window.navigator.userAgent.includes("Safari")) {
return NavigatorType.safari;
}
throw new Error("Couldn't detect navigator type");
}
export function isAndroid(): boolean {
return window.navigator.userAgent.includes("Android");
}