Created
September 23, 2022 15:24
-
-
Save thangman22/f60798c65704de75bc48ddf5e1e3bd65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('backgroundfetchsuccess', event => { | |
event.updateUI({ | |
title: 'Postr.me capturing sucessful', | |
icons: [{ | |
sizes: '512x512', | |
src: '/assets/img/icon-512.png', | |
type: 'image/png' | |
}] | |
}) | |
event.waitUntil( | |
(async () => { | |
try { | |
const cache = await caches.open(event.registration.id) | |
const records = await event.registration.matchAll() | |
const promises = records.map(async record => { | |
const response = await record.responseReady | |
await cache.put(record.request, response) | |
}) | |
await Promise.all(promises) | |
} catch (err) { | |
console.error(err) | |
} | |
})() | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment