const pushLocalNotification = function (title, body) {
window.Notification.requestPermission().then((result) => {
var notification = new window.Notification(title, {
body: body,
//requireInteraction: true,
});
notification.onerror = function (err) {
console.log(err);
};
notification.onclick = function (event) {
if (window.navigator.mozApps) {
var request = window.navigator.mozApps.getSelf();
request.onsuccess = function () {
if (request.result) {
notification.close();
//open app
request.result.launch();
}
};
} else {
window.open(document.location.origin, "_blank");
}
};
notification.onshow = function () {
// notification.close();
};
});
};```