dynamicsmobile
Version:
Allows development of off-line mobile and web business apps over the Dynamics Mobile platform. More info on https://www.dynamicsmobile.com
40 lines • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPlatformType = exports.PlatformType = void 0;
var PlatformType;
(function (PlatformType) {
PlatformType[PlatformType["Web"] = 0] = "Web";
PlatformType[PlatformType["Android"] = 1] = "Android";
PlatformType[PlatformType["iOS"] = 2] = "iOS";
PlatformType[PlatformType["Windows"] = 3] = "Windows";
PlatformType[PlatformType["Test"] = 4] = "Test";
PlatformType[PlatformType["Backend"] = 5] = "Backend";
})(PlatformType || (exports.PlatformType = PlatformType = {}));
function getPlatformType(testableUserAgent) {
if (!testableUserAgent && process && process.env) {
if (process.env.NODE_ENV == "test") {
return PlatformType.Test;
}
}
var userAgent;
if (testableUserAgent)
userAgent = testableUserAgent;
else if (typeof navigator === 'object')
userAgent = navigator.userAgent;
var isIosWebview = /(iPhone|iPod|iPad|Macintosh).*AppleWebKit(?!.*Safari)/i.test(userAgent);
var isAndroidWebview = /wv\)/i.test(userAgent);
var isWindowsWebview = /Edg\//i.test(userAgent);
if (isAndroidWebview)
return PlatformType.Android;
else if (isIosWebview)
return PlatformType.iOS; //app in webview
else
// if window.chrome.webview exists return windows platform, because there is no way to tell from user agent string
// between Win10 WebView2 and Web browser
if (isWindowsWebview && (window.chrome != undefined && window.chrome.webview != undefined))
return PlatformType.Windows;
else
return PlatformType.Web;
}
exports.getPlatformType = getPlatformType;
//# sourceMappingURL=dms-platform-type.js.map