Google Chrome webkit通知撤销权限?打开/关闭

Google Chrome webkit notifications revoke permission? Toggle on/off?

本文关键字:打开 关闭 权限 Chrome webkit 通知 Google      更新时间:2023-09-26

我有webkit通知工作完美,但我想让用户选择关闭他们,如果他们觉得他们讨厌。

我已经搜索了API,但找不到任何与撤销权限有关的内容。

基本上看起来像下面这样…

<input type="button" onclick="window.webkitNotifications.requestPermission();" value="Yes" />
<input type="button" onclick="window.webkitNotifications.revokePermission();" value="No" />

您不能撤销通知权限,它们只能使用chrome配置每个页面的基础上撤销设置>高级设置>隐私设置>内容设置>通知。

如果你不想显示它们,你需要跟踪用户的选择,而不是创建通知,而不是撤销权限。

以下是chromium api:

interface NotificationCenter {
 // Notification factory methods.
 Notification createNotification(in DOMString iconUrl, in DOMString title, in DOMString body) throws(Exception);
 optional Notification createHTMLNotification(in DOMString url) throws(Exception);
 // Permission values
 const unsigned int PERMISSION_ALLOWED = 0;
 const unsigned int PERMISSION_NOT_ALLOWED = 1;
 const unsigned int PERMISSION_DENIED = 2;
 // Permission methods
 int checkPermission();
 void requestPermission(in Function callback);
}