You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
670 B

self.addEventListener("push", function (event) {
let payload;
if (event.data) {
payload = JSON.parse(event.data.text());
}
const title = payload ? payload.title : "Custom Title";
const options = {
body: payload ? payload.body : "Custom body text",
icon: payload ? payload.icon : "icon.png",
badge: payload ? payload.badge : "badge.png",
};
event.waitUntil(self.registration.showNotification(title, options));
});
self.addEventListener('message', function(event) {
const data = event.data;
switch (data.command) {
case 'account':
break;
default:
console.log('Unknown command:', data.command);
}
});