POC: Mobile notification via periodicSync

This commit is contained in:
10G Meow 2023-11-26 13:51:15 +02:00
parent b14749c28f
commit 2aa97cf134
3 changed files with 78 additions and 6 deletions

View file

@ -19,4 +19,18 @@ self.addEventListener("notificationclick", (e) => {
.then((windowClient) => (windowClient ? windowClient.focus() : null));
}),
);
});
});
async function checkNewMessages() {
const cachedCredentials = await caches.open('cachedCredentials');
// Todo...
}
self.addEventListener('periodicsync', (event) => {
if (event.tag === 'check-new-messages') {
// Test if periodicSync notification triggers in Mobile app(created via add to homescreen)
self.registration.showNotification("Notification via periodicSync");
event.waitUntil(checkNewMessages());
}
});