service-worker

Angular Service Workers Routes

时光怂恿深爱的人放手 提交于 2020-01-01 05:15:11
问题 I have built an app with Angular Service worker and it is all working well offline except for the routes. If I go to the base url the app loads fine but if I go to any of the other routes while offline I get an offline error. My ngsw-manifest.json looks like { "routing": { "index": "/index.html", "routes": { "/": { "match": "exact" }, "/home": { "match": "exact" }, "/paramaterlessroutes": { "match": "exact" }, "/routeswithparamaters": { "match": "prefix" } } } } 来源: https://stackoverflow.com

How to handle images offline in a PWA share target?

て烟熏妆下的殇ゞ 提交于 2020-01-01 05:13:08
问题 I can register my Progressive Web App as a share target for images (supported from Chrome Android 76): "share_target": { "action": "/share-target", "method": "POST", "enctype": "multipart/form-data", "params": { "files": [ { "name": "myImage", "accept": ["image/jpeg", "image/png"] } ] } } I can then intercept attempts to share images to the app in a service worker: self.addEventListener('fetch', e => { if (e.request.method === 'POST' && e.request.url.endsWith('/share-target')) { // todo } })

PushManager subscription promise never fulfill nor reject

独自空忆成欢 提交于 2020-01-01 04:55:13
问题 I am currently facing an issue with some Chrome (Chromium) version where the PushManager.subscribe promise from a ServiceWorker stays in a pending state . The code itself is pretty simple : return serviceWorkerRegistration.pushManager.subscribe({ userVisibleOnly: true }); I have a valid and accessible JSON manifest , providing the GCM Sender ID . I also tried different implementations, as described in this post, but the result is still the same. The subscription part works well with every 47+

Cache asset via freshness in Angular 6 Service Worker

会有一股神秘感。 提交于 2020-01-01 02:26:32
问题 I'm trying to integrate the Angular Service Worker into a existing project. If I understood it correctly there are two cases how data gets cached in Angular SW. It is possible to prefetch or lazyupdate the asset data and to cache specific API calls and other XHR requests. What I'm trying to achieve is to load an specific asset first via network, if the request runs into a timeout or is not accessible it will be served via the cache. Just like the freshness strategy when caching API calls. But

What are the downsides to using skipWaiting and clientsClaim with Workbox?

╄→гoц情女王★ 提交于 2019-12-31 10:48:51
问题 By default skipWaiting is set to false in Workbox. Assuming you're only using the Workbox-created service worker for caching, are there any downsides to setting this to true? Without doing so, the next build of your app will ship updated resource urls (from webpack). These urls will be updated in the service worker's precache manifest, but without skipWaiting , the updated service worker will not be activated to take advantage of them, until the user closes their browser and re-opens. These

How to use service workers in Cordova Android app?

人盡茶涼 提交于 2019-12-31 09:13:19
问题 I want to use a service worker in my Cordova Android add as a convenient way to sync some images to and from the server. I notice that this question states that this is not possible, since service workers must be loaded via https: , whereas Cordova will load files via file: . On the other hand, it seems that ionic supports service workers. That implies that they have figured out some way to make this work. However, I am not using ionic. There appears to be a cordova plugin for service workers

clients.openWindow() “Not allowed to open a window.” on a serviceWorker Google Chrome

半城伤御伤魂 提交于 2019-12-30 08:03:14
问题 I'm testing under Chrome Version 42.0.2311.152m and I want to implement to open a window on a notificationclick like in this example: (source: https://developer.mozilla.org/en-US/docs/Web/API/WindowClient ) self.addEventListener('notificationclick', function(event) { console.log('On notification click: ', event.notification.tag); event.notification.close(); // This looks to see if the current is already open and // focuses if it is event.waitUntil(clients.matchAll({ type: "window" }).then

How to register a service worker's scope one directory above where the service_worker.js is located

家住魔仙堡 提交于 2019-12-29 08:29:07
问题 MY directories are as follows. public_html/ sw/ The "sw/" is where I want to put all service workers, but then have those service workers with a scope to all the files in "public_html/". JS <script> if ('serviceWorker' in navigator) { navigator.serviceWorker.register('sw/notifications.js', { scope: '../sw/' }).then(function(reg) { // registration worked console.log('Registration succeeded. Scope is ' + reg.scope); }).catch(function(error) { // registration failed console.log('Registration

serviceworkers focus tab: clients is empty on notificationclick

戏子无情 提交于 2019-12-29 06:38:12
问题 I have a common serviceworker escenario, where I want catch a notification click and focus the tab where the notification has come from. However, clients variable is always empty, its lenght is 0 console.log("sw startup"); self.addEventListener('install', function (event) { console.log("SW installed"); }); self.addEventListener('activate', function (event) { console.log("SW activated"); }); self.addEventListener("notificationclick", function (e) { // Android doesn't automatically close

Using multiple javascript service workers at the same domain but different folders

你离开我真会死。 提交于 2019-12-29 04:43:29
问题 My website offers an array of web apps for each client. Each client has a different mix of apps that can be used. Each web app is a hosted in a different folder. So I need to cache for each client only it's allowed web apps instead of caching all the apps, many of them he the user, will not use at all. I naively created a global service worker for the shell of the website and custom named service worker for each folder or app. However I noticed that after the first service worker, say sw