WebXR.ts navigator[xr].isSessionSupported issue

Hi again! I’m having an issue that prevents me from finishing the build & deploy to glitch, the error seems to be with the navigator, the method isSessionSupported of the XRSystem shows as unknown anyone having a problem with this?


Original Post on Discord

by user 262331051802755072

Hi, I believe this is already fixed on latest version, can you try updating?

Hi herbst, forgot to answer here, yes, it is fixed, thanks a ton!

by user 262331051802755072

Wonderful, great to know!

Hi, does anyone knows if there’s a way to get the navigator (desktop, mobile, vr) the user is running the webapp?

by user 939271426349862963

Hi, we have some utility methods for common scenarios:

import { Behaviour } from "@needle-tools/engine";
import { isMobileDevice, isiOS, isMozillaXR, isSafari, isQuest } from "@needle-tools/engine/engine/engine_utils";

// Documentation → https://docs.needle.tools/scripting

export class DeviceDetection extends Behaviour {
    
    start() {
        console.log("UserAgent", window.navigator.userAgent);

        console.log("isMobileDevice", isMobileDevice());
        console.log("isiOSDevice", isiOS());
        console.log("isMozillaXR", isMozillaXR());
        console.log("isSafari", isSafari());
        console.log("isQuest", isQuest());
    }
}

All of these are derived from window.navigator.userAgent.
More generally, if you want to know what the user agent of a specific device is, you can

  • append ?console to the URL and
  • then tap on the console icon in the bottom right,
  • then on “System”, read the user agent there

Like this
20230201-235923_chrome.mp4

Typically it’s better to distinguish by device categories (like the methods above) and not directly by a specific user agent, but of course depends on what you want to do :slightly_smiling_face:

I’ll take note that we add a sample for this; I extended the script above with balloon messages:
20230202-001716_chrome.mp4