【问题标题】:Remove persistent notification from list of notifications (Notifications API)从通知列表中删除持久通知(通知 API)
【发布时间】:2016-08-07 13:48:51
【问题描述】:

当从服务工作者调用self.registration.getNotifications({ tag: tag }) 时,返回的数组总是包含已被替换的旧通知。例如:

showNotification('A', { tag: 'abc' }) // Displays the first notification
getNotifications({ tag: 'abc' }) // Returns [ NotificationA ]
showNotification('B', { tag: 'abc' }) // Replaces the previous notification
getNotifications({ tag: 'abc' }) // Returns [ NotificationB, NotificationA ]
showNotification('C', { tag: 'abc' }) // Replaces the previous notification
getNotifications({ tag: 'abc' }) // Returns [ NotificationC, NotificationB, NotificationA ]

【问题讨论】:

    标签: google-chrome push-notification notifications web-push


    【解决方案1】:

    尽管通知 API 规范对 steps for replacing a notification 很清楚:

    1. ...
    2. 在通知列表中的相同位置将旧的替换为新的。
    3. ...

    实现将旧通知保留在列表中,直到从代码中显式调用 .close() 或直到用户单击通知本身上的 [x] 按钮,隐式运行 .close()

    【讨论】:

      猜你喜欢
      • 2011-04-05
      • 1970-01-01
      • 2015-04-24
      • 2018-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多