fiddling around with push notifications

This commit is contained in:
Jonas Weinz 2019-03-10 17:33:30 +01:00
parent 32bf577dc1
commit 2089c35c6c
2 changed files with 6 additions and 26 deletions

26
main.js
View File

@ -17,28 +17,4 @@ var sidebar = new Sidebar(create_game_container, setting_container, control_cont
window.addEventListener("resize", function() { window.addEventListener("resize", function() {
var tilesize = getComputedStyle(document.body).getPropertyValue("--tile-size"); var tilesize = getComputedStyle(document.body).getPropertyValue("--tile-size");
grid.on_screen_orientation_change(tilesize, tilesize); grid.on_screen_orientation_change(tilesize, tilesize);
}); })
window.addEventListener('notificationclick', function(event) {
event.waitUntil(async function() {
const allClients = await clients.matchAll({
includeUncontrolled: true
});
var instance = None;
// Let's see if we already have a window open:
for (const client of allClients) {
client.focus();
instance = client;
break;
}
// If we didn't find an existing window,
// open a new one:
if (!instance) {
instance = await clients.openWindow(rel_home);
}
}());
});

6
sw.js
View File

@ -30,4 +30,8 @@ self.addEventListener('install', function(e) {
return response || fetch(event.request); return response || fetch(event.request);
}) })
); );
}); });
self.addEventListener('notificationclick', function (event) {
console.log ("push message clicked");
});