We have the current scenario where user continues to receive notifications from the site even after closing the browser. Please let us know how to address it, appreciate your help.
if ("serviceWorker" in navigator) {
navigator.serviceWorker
.register("./firebase-messaging-sw.js")
.then(function (registration) {
const mregn = registration;
page.messaging = firebase.messaging();
page.messaging
.requestPermission()
.then(function () {
// get the token in the form of promise
return page.messaging.getToken(
{ serviceWorkerRegistration: mregn }
);
})
.then(function (token) {
})
.catch(function (err) {
});
})
.catch(function (err) {
console.log("Registration failed, error:", err);
});
}
This is what we tried to unregister but not working
beforeDestroy: function () {
if ("serviceWorker" in navigator) {
navigator.serviceWorker
.unregister()
.then(function (status) {
});
}
},