react-web-native-sketch
Version:
[TODO: We need an overview of how this can be used via npm vs as a local package]
36 lines • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var localForage = require("localforage");
var enums_1 = require("../../utils/enums");
exports.isWeb = true;
exports.isIOS = false;
exports.isAndroid = false;
exports.isSketch = false;
exports.getWindowHeight = function () { return window.innerHeight; };
exports.getWindowWidth = function () { return window.innerWidth; };
exports.getStorage = function () {
return localForage;
};
/**
* Determine the mobile operating system.
* This function returns one of 'iOS', 'Android', 'Windows Phone', or 'unknown'.
*
* @returns {Object}
*/
function getPlatform() {
var userAgent = navigator.userAgent || navigator.vendor || window.opera || '';
// Windows Phone must come first because its UA also contains 'Android'
if (/windows phone/i.test(userAgent)) {
return enums_1.PLATFORM.WEB_WINDOWS_PHONE;
}
if (/android/i.test(userAgent)) {
return enums_1.PLATFORM.WEB_ANDROID;
}
// iOS detection from: http://stackoverflow.com/a/9039885/177710
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
return enums_1.PLATFORM.WEB_IOS;
}
return enums_1.PLATFORM.WEB;
}
exports.getPlatform = getPlatform;
//# sourceMappingURL=platform.js.map