diff options
| author | Kit La Touche <kit@transneptune.net> | 2025-07-30 23:08:40 -0400 |
|---|---|---|
| committer | Kit La Touche <kit@transneptune.net> | 2025-07-30 23:08:40 -0400 |
| commit | ed5e175a806f45469a6e5504ba0d3f5246997fad (patch) | |
| tree | 0d4233c57596186b86d165640ca4721e7495567d /ui/service-worker.js | |
| parent | b63380b251d04dd92f06aa5bbc22a72ca3e4bf8e (diff) | |
Test receiving push events when backgrounded
And thus also displaying notifications.
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 + }) ); }); |
