diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-07-19 03:19:14 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-07-19 03:19:14 +0200 |
commit | bbb50922bf2d80e6b510eaca35477efb75704722 (patch) | |
tree | c18316bd61ca52c09166b88084eaa76554f0ecf6 /web-build/expo-service-worker.js | |
parent | 611085d403550303dbf66ec3f9152f772377f1c4 (diff) |
web build with offline support
Diffstat (limited to 'web-build/expo-service-worker.js')
-rw-r--r-- | web-build/expo-service-worker.js | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/web-build/expo-service-worker.js b/web-build/expo-service-worker.js new file mode 100644 index 0000000..50b4b60 --- /dev/null +++ b/web-build/expo-service-worker.js @@ -0,0 +1 @@ +self.addEventListener("message",t=>{let i;if("string"===typeof t.data)try{i=JSON.parse(t.data)}catch(e){}i&&i.fromExpoWebClient&&(self.notificationIcon=i.fromExpoWebClient.notificationIcon)}),self.addEventListener("push",t=>{let i={};try{i=t.data.json()}catch(a){i={title:"",body:t.data.text()}}const e=i.title,n=i.data||i.custom||{},o={body:i.body,data:n};o.icon=n._icon||i.icon||self.notificationIcon||null,o.image=n._richContent&&n._richContent.image?o.data._richContent.image:i.image,o.tag=n._tag||i.collapseKey,o.tag&&(o.renotify=n._renotify),t.waitUntil(self.registration.showNotification(e,o))}),self.addEventListener("notificationclick",t=>{t.notification.close(),t.waitUntil((async()=>{const i=await self.clients.matchAll({includeUncontrolled:!0});let e;const n=t.notification.data._webPath||"/";for(const t of i){if(new URL(t.url).pathname===n){t.focus(),e=t;break}}e||(e=await self.clients.openWindow(n)),e.postMessage({origin:"selected",data:t.notification.data,remote:!t.notification._isLocal})})())}),self.importScripts("service-worker.js");
\ No newline at end of file |