【问题标题】:Push Notification for on Desktop keeps popping back after closing it桌面上的推送通知在关闭后不断弹出
【发布时间】:2019-04-29 19:31:20
【问题描述】:

我正在使用 Node、Express 和 Socket.io 构建一个聊天应用程序

这是它的链接:https://shahchat.herokuapp.com/

这是一个样本测试工作

由于某种原因,试图关闭弹出窗口正在一次又一次地重新加载。

任何帮助或建议将不胜感激

JS 代码

function notifyMe(user, message) {
        // Let's check if the browser supports notifications
        if (!("Notification" in window)) {
          alert("This browser does not support desktop notification");
        }

        // Let's check if the user is okay to get some notification
        else if (Notification.permission === "granted") {
          // If it's okay let's create a notification
          var options = {
            title: user,
            body: message,
            dir: "ltr"
          };
          var notification = new Notification(user, options);
      }

套接字代码

 socket.once("notify everyone", data => {
          notifyMe(data.user, data.comment);
        });

【问题讨论】:

    标签: node.js express socket.io


    【解决方案1】:

    您可以使用Chrome Notification,它适用于桌面端和移动端。

    【讨论】:

      猜你喜欢
      • 2021-03-08
      • 2018-07-14
      • 1970-01-01
      • 1970-01-01
      • 2017-01-14
      • 2016-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多