From: Chris Fulljames Date: Fri, 23 May 2025 01:02:08 +0000 (-0400) Subject: Wait until notification is displayed X-Git-Url: https://littlesong.place/gitweb/?a=commitdiff_plain;h=db20bedbb70cfad024dca0e5003585cb26e391a8;p=littlesongplace.git Wait until notification is displayed --- diff --git a/src/littlesongplace/static/service.js b/src/littlesongplace/static/service.js index 91456af..fc25903 100644 --- a/src/littlesongplace/static/service.js +++ b/src/littlesongplace/static/service.js @@ -1,5 +1,4 @@ self.addEventListener("activate", async () => { - console.log("hello?"); try { // TODO: Use VAPID key const options = {}; @@ -15,7 +14,7 @@ self.addEventListener("activate", async () => { console.log(response); } catch (err) { - console.log("Error", err); + console.log("Error while activating service:", err); } }); @@ -23,7 +22,7 @@ self.addEventListener("activate", async () => { self.addEventListener("push", (event) => { if (event.data) { const data = event.data.json(); - self.registration.showNotification(data.title, {body: data.body}); + event.waitUntil(self.registration.showNotification(data.title, {body: data.body})); } });