diff options
Diffstat (limited to 'ui/service-worker.js')
| -rw-r--r-- | ui/service-worker.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ui/service-worker.js b/ui/service-worker.js index 319b251..a88c5a2 100644 --- a/ui/service-worker.js +++ b/ui/service-worker.js @@ -54,10 +54,12 @@ self.addEventListener('fetch', (event) => { }); self.addEventListener('push', (event) => { - const payload = event.data?.text() ?? "no payload"; + // If the data isn't json, this dies hard: + const payload = event.data?.json() ?? null; event.waitUntil( - self.registration.showNotification("ServiceWorker Cookbook", { - body: payload, - }), + // How do we control the action you get when you click the notification? + self.registration.showNotification(payload.title, { + body: payload.body + }) ); }); |
