How to use the detect-browser.detectOS function in detect-browser

To help you get started, we’ve selected a few detect-browser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / hubs / src / hub.js View on Github external
await store.initProfile();

  const canvas = document.querySelector(".a-canvas");
  canvas.classList.add("a-hidden");

  warmSerializeElement();

  if (!window.WebAssembly) {
    remountUI({ showWebAssemblyDialog: true });
    return;
  }

  // If we are on iOS but we don't have the mediaDevices API, then we are likely in a Firefox or Chrome WebView,
  // or a WebView preview used in apps like Twitter and Discord. So we show the dialog that tells users to open
  // the room in the real Safari.
  const detectedOS = detectOS(navigator.userAgent);
  if (detectedOS === "iOS" && !navigator.mediaDevices) {
    remountUI({ showSafariDialog: true });
    return;
  }

  const hubId = qs.get("hub_id") || document.location.pathname.substring(1).split("/")[0];
  console.log(`Hub ID: ${hubId}`);

  const subscriptions = new Subscriptions(hubId);

  if (navigator.serviceWorker) {
    try {
      navigator.serviceWorker
        .register("/hub.service.js")
        .then(() => {
          navigator.serviceWorker.ready
github mozilla / hubs / src / hub.js View on Github external
await store.initProfile();

  const canvas = document.querySelector(".a-canvas");
  canvas.classList.add("a-hidden");

  warmSerializeElement();

  if (!window.WebAssembly) {
    remountUI({ showWebAssemblyDialog: true });
    return;
  }

  // If we are on iOS but we don't have the mediaDevices API, then we are likely in a Firefox or Chrome WebView,
  // or a WebView preview used in apps like Twitter and Discord. So we show the dialog that tells users to open
  // the room in the real Safari.
  const detectedOS = detectOS(navigator.userAgent);
  if (detectedOS === "iOS" && !navigator.mediaDevices) {
    remountUI({ showSafariDialog: true });
    return;
  }

  // HACK: On Safari for iOS & MacOS, if mic permission is not granted, subscriber webrtc negotiation fails.
  // So we need to insist on microphone grants to continue.
  const browser = detect();
  if (["iOS", "Mac OS"].includes(detectedOS) && ["safari", "ios"].includes(browser.name)) {
    try {
      await navigator.mediaDevices.getUserMedia({ audio: true });
    } catch (e) {
      remountUI({ showSafariMicDialog: true });
      return;
    }
  }
github tensorflow / tfjs / tfjs / integration_tests / models / common.ts View on Github external
export function getBrowserEnvironmentType(): BrowserEnvironmentType {
  const osName = detectBrowser.detectOS(navigator.userAgent).toLowerCase();
  const browserName = detectBrowser.detect().name.toLowerCase();
  return `${browserName}-${osName}` as BrowserEnvironmentType;
}

detect-browser

Unpack a browser type and version from the useragent string

MIT
Latest version published 2 years ago

Package Health Score

71 / 100
Full package analysis