bigbluebutton-Github/bigbluebutton-html5/imports/utils/deviceInfo.js

35 lines
1.0 KiB
JavaScript
Raw Normal View History

2021-04-01 01:13:36 +08:00
import Bowser from 'bowser';
2021-04-01 01:13:36 +08:00
const BOWSER_RESULTS = Bowser.parse(window.navigator.userAgent);
2021-04-01 01:13:36 +08:00
const isPhone = BOWSER_RESULTS.platform.type === 'mobile';
// we need a 'hack' to correctly detect ipads with ios > 13
const isTablet = BOWSER_RESULTS.platform.type === 'tablet' || (BOWSER_RESULTS.os.name === 'macOS' && window.navigator.maxTouchPoints > 0);
const isMobile = isPhone || isTablet;
const hasMediaDevices = !!navigator.mediaDevices;
const osName = BOWSER_RESULTS.os.name;
const osVersion = BOWSER_RESULTS.os.version;
const isIos = osName === 'iOS';
const isMacos = osName === 'macOS';
const isIphone = !!(window.navigator.userAgent.match(/iPhone/i));
const SUPPORTED_IOS_VERSION = 12.2;
const isIosVersionSupported = () => parseFloat(osVersion) >= SUPPORTED_IOS_VERSION;
2021-04-01 01:13:36 +08:00
const isPortrait = () => window.innerHeight > window.innerWidth;
2021-04-01 01:13:36 +08:00
const deviceInfo = {
isTablet,
isPhone,
isMobile,
hasMediaDevices,
osName,
isPortrait,
isIos,
isMacos,
isIphone,
isIosVersionSupported,
2021-04-01 01:13:36 +08:00
};
export default deviceInfo;