implement on notification click

This commit is contained in:
Tor Hveem 2015-12-22 14:40:01 +01:00
parent 1565c0e72d
commit 952da6d9dd

View file

@ -20,3 +20,27 @@ this.addEventListener('push', function(event) {
tag: 'my-tag' tag: 'my-tag'
})); }));
}); });
this.onnotificationclick = function(event) {
// Android doesn't close the notification when you click on it
// See: http://crbug.com/463146
event.notification.close();
// This looks to see if the current is already open and
// focuses if it is
event.waitUntil(clients.matchAll({
type: "window"
}).then(function(clientList) {
for (var i = 0; i < clientList.length; i++) {
var client = clientList[i];
if ('focus' in client) {
return client.focus();
}
}
/*
if (clients.openWindow) {
return clients.openWindow('/glowing-bear/');
}
*/
}));
};