mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 17:15:48 +00:00
refactor: improve ios vision os detection
This commit is contained in:
parent
8e87d2515b
commit
c8d107d036
1 changed files with 14 additions and 6 deletions
|
|
@ -11,13 +11,21 @@ const APPLE_MOBILE_DEVICES = [
|
||||||
|
|
||||||
const { userAgent, platform, maxTouchPoints } = globalThis.navigator;
|
const { userAgent, platform, maxTouchPoints } = globalThis.navigator;
|
||||||
|
|
||||||
// this detects ipad properly in safari
|
// Vision Pro uniquely supports the WebXR Device API (navigator.xr),
|
||||||
// while bowser does not
|
// while iPads and iPhones do not — this is the most reliable discriminator.
|
||||||
const isIOS = APPLE_MOBILE_DEVICES.includes(platform) || (userAgent.includes('Mac') && 'ontouchend' in document);
|
// Both Vision Pro and iPads (iPadOS 13+) report 'Macintosh' in the UA
|
||||||
|
// and have maxTouchPoints > 1, so we cannot rely on those alone.
|
||||||
|
const isMacLikeWithTouch = userAgent.includes('Macintosh') && maxTouchPoints > 1;
|
||||||
|
const isVisionOS = isMacLikeWithTouch && 'xr' in globalThis.navigator;
|
||||||
|
|
||||||
// Edge case: iPad is included in this function
|
// Detect iOS/iPadOS devices:
|
||||||
// Keep in mind maxTouchPoints for Vision Pro might change in the future
|
// - Older iPads expose 'iPad' in navigator.platform
|
||||||
const isVisionOS = userAgent.includes('Macintosh') && maxTouchPoints === 5;
|
// - iPadOS 13+ exposes 'MacIntel' but has touch support ('ontouchend' in document)
|
||||||
|
// - Exclude Vision OS devices which also pass the touch check
|
||||||
|
const isIOS = !isVisionOS && (
|
||||||
|
APPLE_MOBILE_DEVICES.includes(platform) ||
|
||||||
|
(userAgent.includes('Mac') && 'ontouchend' in document)
|
||||||
|
);
|
||||||
|
|
||||||
const bowser = Bowser.getParser(userAgent);
|
const bowser = Bowser.getParser(userAgent);
|
||||||
const os = bowser.getOSName().toLowerCase();
|
const os = bowser.getOSName().toLowerCase();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue