Vaadin桌面通知

Vaadin桌面通知,vaadin,Vaadin,Vaadin中是否支持html5浏览器的“桌面通知”?我找了这个,找不到任何具体的东西 我尝试过这样的事情,但运气不好 JavaScript.getCurrent().execute( "if (window.webkitNotifications) {" + "if (window.webkitNotifications.checkPermission() == 0) { // 0 is PERMISSION_AL

Vaadin中是否支持html5浏览器的“桌面通知”?我找了这个,找不到任何具体的东西

我尝试过这样的事情,但运气不好

        JavaScript.getCurrent().execute(
            "if (window.webkitNotifications) {" +
                    "if (window.webkitNotifications.checkPermission() == 0) { // 0 is PERMISSION_ALLOWED" +
            "    window.webkitNotifications.createNotification(" +
            "        'icon.png', 'Notification Title', 'Notification content...');" +
            "  } else {\n" +
            "    window.webkitNotifications.requestPermission();" +
            "  } " +
            "} else { " +
            "   console.log('no notifications')" +
            "}");

使用旧api尝试的vaadin 8,许多版本都不支持它。工作组应:

  JavaScript.getCurrent().execute(
        "  if (!(\"Notification\" in window)) { " +
        "    alert(\"This browser does not support system notifications\"); " +
        "  } else if (Notification.permission === \"granted\") { " +
        "    new Notification(\"Hi there!\"); " +
        "  } else if (Notification.permission !== 'denied') { " +
        "    Notification.requestPermission(function (permission) { " +
        "      if (permission === \"granted\") { " +
        "        Notification(\"Hi there!\"); " +
        "      } " +
        "    }); " +
        "  } "
  );
但不能说这是一个好方法

有一个用于vaadin 7的插件,您可以将其应用于8。或者创建一个或至少是一个能让使用更容易的