UNPKG

@beenotung/tslib

Version:
23 lines (22 loc) 691 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.detectMobilePlatform = detectMobilePlatform; function detectMobilePlatform() { if (typeof navigator === 'undefined' && (typeof window === 'undefined' || typeof window.opera === 'undefined')) { // not browser env return 'unknown'; } const userAgent = navigator.userAgent || navigator.vendor || window.opera; if (/windows phone/i.test(userAgent)) { return 'Windows Phone'; } if (/android/i.test(userAgent)) { return 'Android'; } if (/ipad|iphone|ipod/i.test(userAgent)) { return 'iOS'; } return 'unknown'; }