2021-02-09 02:35:03 -05:00
|
|
|
|
|
|
|
self.addEventListener('push', function (event) {
|
2021-02-09 04:46:20 -05:00
|
|
|
console.log('Service Worker push', JSON.stringify(event));
|
2021-02-09 02:35:03 -05:00
|
|
|
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);
|
2021-02-09 04:46:20 -05:00
|
|
|
};
|