blob: e344b45fd8cb6d1431ee3457c3acba76a8e62a40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
self.addEventListener('install', e => e.waitUntil(skipWaiting()));
self.addEventListener('activate', e => e.waitUntil(clients.claim()));
self.addEventListener('message', async e => {
const method = e.data;
const promise = method === 'subscribe' ?
self.registration.pushManager.subscribe({userVisibleOnly: true}) :
Promise.resolve();
const message = await promise
.then(() => {
return `${method}: Unexpectedly started`;
})
.catch((e) => {
return e.message;
});
e.source.postMessage(message);
});
|