diff --git a/components/serviceworker.js b/components/serviceworker.js index 438155080..174aa3126 100644 --- a/components/serviceworker.js +++ b/components/serviceworker.js @@ -99,7 +99,15 @@ export const ServiceWorkerProvider = ({ children }) => { if (pushSubscription) { return unsubscribeFromPushNotifications(pushSubscription) } - return subscribeToPushNotifications() + return subscribeToPushNotifications().then(async () => { + // request persistent storage: https://web.dev/learn/pwa/offline-data#data_persistence + const persisted = await navigator?.storage?.persisted?.() + if (!persisted && navigator?.storage?.persist) { + return navigator.storage.persist().then(persistent => { + logger.info('persistent storage:', persistent) + }).catch(logger.error) + } + }) }) useEffect(() => {