Add dismiss functionality to html5 notifications. (#2435)

* Add dismiss function to notifications.

* fix let -> const
This commit is contained in:
Tommy Jonsson 2019-01-10 22:46:53 +01:00 committed by Paulus Schoutsen
parent a2ef8bbe70
commit 326931277e

View File

@ -72,6 +72,18 @@ function initPushNotifications() {
var data;
if (event.data) {
data = event.data.json();
if (data.dismiss) {
event.waitUntil(
self.registration
.getNotifications({ tag: data.tag })
.then(function(notifications) {
for (const n of notifications) {
n.close();
}
})
);
return;
}
event.waitUntil(
self.registration
.showNotification(data.title, data)