bigbluebutton-Github/bigbluebutton-html5/imports/utils/deviceInfo.js
2021-03-31 14:13:36 -03:00

24 lines
678 B
JavaScript
Executable File

import Bowser from 'bowser';
const BOWSER_RESULTS = Bowser.parse(window.navigator.userAgent);
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 isPortrait = () => window.innerHeight > window.innerWidth;
const deviceInfo = {
isTablet,
isPhone,
isMobile,
hasMediaDevices,
osName,
isPortrait,
};
export default deviceInfo;