Browse Source

include the data in the logged info for a service worker "push"

pull/100/head
Trent Larson 11 months ago
parent
commit
853eb3c623
  1. 10
      sw_scripts/additional-scripts.js

10
sw_scripts/additional-scripts.js

@ -28,13 +28,17 @@ function logConsoleAndDb(message, arg1, arg2) {
} }
self.addEventListener("push", function (event) { self.addEventListener("push", function (event) {
logConsoleAndDb("Service worker received a push event.", event); let text = null;
if (event.data) {
text = event.data.text();
}
logConsoleAndDb("Service worker received a push event.", text, event);
event.waitUntil( event.waitUntil(
(async () => { (async () => {
try { try {
let payload; let payload;
if (event.data) { if (text) {
payload = JSON.parse(event.data.text()); payload = JSON.parse(text);
} }
const message = await self.getNotificationCount(); const message = await self.getNotificationCount();
if (message) { if (message) {

Loading…
Cancel
Save