Answer the question
In order to leave comments, you need to log in
How to set url on click on push notification from web worker?
There is a small web worker that handles push notifications from the server.
self.addEventListener('push', function (event) {
if (!(self.Notification && self.Notification.permission === 'granted')) {
return;
}
const sendNotification = body => {
const title = "Web Push example";
return self.registration.showNotification(title, {
body,
});
};
if (event.data) {
let message = event.data.json();
event.waitUntil(sendNotification(message.body));
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question