mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-25 22:55:52 -05:00
18 lines
569 B
JavaScript
18 lines
569 B
JavaScript
|
|
self.addEventListener('push', function (event) {
|
|
console.log('Service Worker push', JSON.stringify(event));
|
|
if (event.data) {
|
|
console.log("Push event!! ", event.data.text());
|
|
showLocalNotification("Yolo", event.data.text(), self.registration);
|
|
} else {
|
|
console.log("Push event but no data");
|
|
}
|
|
});
|
|
|
|
const showLocalNotification = function(title, body, swRegistration) {
|
|
const options = {
|
|
body
|
|
// here you can add more properties like icon, image, vibrate, etc.
|
|
};
|
|
swRegistration.showNotification(title, options);
|
|
}; |