|
|
@ -28,13 +28,17 @@ function logConsoleAndDb(message, arg1, arg2) { |
|
|
|
} |
|
|
|
|
|
|
|
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( |
|
|
|
(async () => { |
|
|
|
try { |
|
|
|
let payload; |
|
|
|
if (event.data) { |
|
|
|
payload = JSON.parse(event.data.text()); |
|
|
|
if (text) { |
|
|
|
payload = JSON.parse(text); |
|
|
|
} |
|
|
|
const message = await self.getNotificationCount(); |
|
|
|
if (message) { |
|
|
|