fixes
This commit is contained in:
parent
638e9bf505
commit
c624d7e098
1 changed files with 4 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
|||
var periodicSyncNewMsgReminderText;
|
||||
|
||||
// Notification click event listener
|
||||
self.addEventListener("notificationclick", (e) => {
|
||||
e.notification.close();
|
||||
|
|
@ -21,7 +22,7 @@ self.addEventListener("notificationclick", (e) => {
|
|||
});
|
||||
|
||||
self.addEventListener("message", (event) => {
|
||||
periodicSyncNewMsgReminderText = event.data || "You may have new messages"
|
||||
periodicSyncNewMsgReminderText = event.data;
|
||||
});
|
||||
|
||||
async function checkNewMessages() {
|
||||
|
|
@ -33,7 +34,8 @@ async function checkNewMessages() {
|
|||
// see browser compatibility: https://developer.mozilla.org/en-US/docs/Web/API/Web_Periodic_Background_Synchronization_API#browser_compatibility
|
||||
self.addEventListener('periodicsync', (event) => {
|
||||
if (event.tag === 'check-new-messages') {
|
||||
self.registration.showNotification(periodicSyncNewMsgReminderText);
|
||||
let notificationTitle = periodicSyncNewMsgReminderText || "You may have new messages";
|
||||
self.registration.showNotification(notificationTitle);
|
||||
|
||||
event.waitUntil(checkNewMessages());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue