I was having the same issue, then I try putting event.preventDefault() and worked. My notificationclick event looked like this:
self.addEventListener("notificationclick", (event) => {
event.preventDefault();
let distUrl = self.location.origin + "/specific-path";
const apntId = event.notification.data?.apntId;
if (apntId) distUrl = self.location.origin + "/other-path/" + apntId;
event.notification.close();
event.waitUntil(
self.clients.matchAll({ type: "window", includeUncontrolled: true }).then((clients) => {
if (clients.length > 0) {
const client = clients[0];
client.navigate(distUrl);
client.focus();
return;
} else event.waitUntil(self.clients.openWindow(distUrl));
})
);
});
Post
Replies
Boosts
Views
Activity
I was having the same issue, then I try putting event.preventDefault() and worked. My notificationclick event looked like this:
self.addEventListener("notificationclick", (event) => {
event.preventDefault();
let distUrl = self.location.origin + "/specific-path";
const apntId = event.notification.data?.apntId;
if (apntId) distUrl = self.location.origin + "/other-path/" + apntId;
event.notification.close();
event.waitUntil(
self.clients.matchAll({ type: "window", includeUncontrolled: true }).then((clients) => {
if (clients.length > 0) {
const client = clients[0];
client.navigate(distUrl);
client.focus();
return;
} else event.waitUntil(self.clients.openWindow(distUrl));
})
);
});