首页 > 解决方案 > 用于浏览器通知的 Web 通知 API 在 Windows 机器上工作正常,但在 VDI 窗口中不工作

问题描述

我面临一个奇怪的问题。实际上,我已经在我们的 react.js 代码中实现了通知 API(https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API),以在屏幕上不活动时获取浏览器通知以通知用户特定时间。此功能与 Mac、Windows chrome 完美配合。但不适用于 VDI Windows 机器。我们需要让它在 VDI windows 机器上运行,因为我们的应用程序代理只能从那里访问它。以下是我在 UI 上与我们的 reactjs 应用程序集成的代码。

/** this fn shows the borwser notification before 1 minute of warning popup */
  const showBrowserNotification = () => {
    if (Notification.permission === 'granted') {
      /* eslint-disable no-new */
      new Notification('Are you still here!', {
        body: 'Your Casa session is about to expire!',
        icon: favicon
      })
    } else if (Notification.permission !== 'denied') {
      Notification.requestPermission().then(() => {
      /* eslint-disable no-new */
        new Notification('Are you still here!', {
          body: 'Your Casa session is about to expire!',
          icon: favicon
        })
      })
    }
  }

我担心的是为什么它可以在 Windows 机器上工作,但不能在 VDI 窗口上工作。? 我们在这两个地方都使用 Windows 10。请从 windows 和 mac chrome 机器上找到附加的屏幕截图在此处输入图像描述

标签: javascriptreactjswindowsbrowsernotifications

解决方案


推荐阅读