aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/service-worker.ts30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/service-worker.ts b/src/service-worker.ts
index 21de63a2..d7cc2cdd 100644
--- a/src/service-worker.ts
+++ b/src/service-worker.ts
@@ -125,17 +125,25 @@ sw.addEventListener('push', async (event: PushEvent) => {
console.error(error);
}
- // Ref. https://github.com/firebase/quickstart-js/issues/126#issuecomment-504081087
- return new Promise((resolve) => {
- (resolve as unknown as () => void)();
- setTimeout(() => {
- sw.registration.getNotifications().then((notifications) => {
- notifications.forEach((notification) => {
- if (notification.tag !== 'notification') notification.close();
- });
- });
- }, 10);
- });
+ if (navigator.userAgent.includes('Chrome')) {
+ sw.registration.showNotification('due.moe', {
+ body: 'No new notifications',
+ icon: '/favicon-196x196.png',
+ tag: 'notification-1'
+ });
+
+ // Ref. https://github.com/firebase/quickstart-js/issues/126#issuecomment-504081087
+ new Promise((resolve) => {
+ (resolve as unknown as () => void)();
+ setTimeout(
+ () =>
+ sw.registration
+ .getNotifications()
+ .then((notifications) => notifications.forEach((notification) => notification.close())),
+ 10
+ );
+ });
+ }
});
sw.addEventListener('notificationclick', (event: NotificationEvent) => {