service-worker

FCM: Cannot click notification

别等时光非礼了梦想. 提交于 2019-12-03 12:23:12
I'm using the recently release FCM messaging support for push notifications on the chrome. When my app is in the background, I get the notification but nothing happens when I click the notification. How to I specify the URL which should open when the user clicks the notification? (I understand how its done using the pure service worker concept using the notificationclick event, I want to know how to do that using FCM messaging .) messaging.setBackgroundMessageHandler(function(payload) { var data = payload || {}; var shinyData = decoder.run(data); console.log('[firebase-messaging-sw.js]

navigator.serviceWorker.controller is null until page refresh

て烟熏妆下的殇ゞ 提交于 2019-12-03 12:09:25
I work with angularjs and use service worker to receive push notification. but navigator.serviceWorker.controller is null until page refresh,and I don't know how to do to solve this problem some code of serviceworker : self.addEventListener('push', pwServiceWorker.pushReceived); self.addEventListener('notificationclick', pwServiceWorker.notificationClicked); // refresh caches self.addEventListener('activate', function (event) { event.waitUntil( caches.keys().then(function (cacheNames) { return Promise.all( cacheNames.map(function (cacheName) { return caches.delete(cacheName); }) ); }) ); });

Service Workers not updating

泄露秘密 提交于 2019-12-03 11:41:55
I have a service worker installed in my website, everything works fine, except when I push an update to the cached files, in fact; they stay catched forever and I seem to be unable to invalidate the cache unless I unsubscribe the worker from the `chrome://serviceworker-internals/ const STATIC_CACHE_NAME = 'static-cache-v1'; const APP_CACHE_NAME = 'app-cache-#VERSION'; const CACHE_APP = [ '/', '/app/app.js' ] const CACHE_STATIC = [ 'https://fonts.googleapis.com/css?family=Roboto:400,300,500,700', 'https://cdnjs.cloudflare.com/ajax/libs/normalize/4.1.1/normalize.min.css' ] self.addEventListener(

Comparison between service worker and AppCache

跟風遠走 提交于 2019-12-03 11:41:02
What are the core differences between service worker and AppCache. What are the pros and cons of each and when to prefer one over another . The primary difference is that AppCache is a high-level, declarative API, with which you specify the set of resources you'd like the browser to cache; whereas Service Worker is a low-level, imperative, event-driven API with which you write a script that can intercept fetch events and cache their responses along with doing other things (like displaying push notifications). The pros and cons are largely a function of API design: theoretically, AppCache is

navigator.serviceWorker.controller is always null

假如想象 提交于 2019-12-03 11:20:47
I have the problem that after registering the serviceWorker the navigator.serviceWorker.controller is always null. I never do a force refresh and just refresh the page. I test it with Google Chrome 42.0.2311.152 m (32-Bit). var currentServiceWorker = null; navigator.serviceWorker.register(SERVICE_WORKER_URL).then(function(serviceWorkerRegistration { if (navigator.serviceWorker.controller) { currentServiceWorker = navigator.serviceWorker.controller; } else { currentServiceWorker = serviceWorkerRegistration.active; } }); According to this: The controller read-only property of the

Storing REST requests with service workers to sync them

天大地大妈咪最大 提交于 2019-12-03 10:30:29
问题 I'm thinking about taking my application to offline using service workers. I'm already achieving satisfying results with caching resources, but I also have to check onfetch whether I'm connected to the internet, if not - store the request, and push it onsync. I understand, that future onsync will help with that, but I need - even temporary - solution for that. I've tried just to store the requests in an array within worker, but it's not persistent - doesn't work after computer restart (while

What does event.waitUntil do in service worker and why is it needed?

大兔子大兔子 提交于 2019-12-03 10:29:09
问题 MDN suggests that you do the following to create and populate service worker cache: this.addEventListener('install', function(event) { event.waitUntil( caches.open('v1').then(function(cache) { return cache.addAll([ '/sw-test/', '/sw-test/index.html', ... etc ... ]); }) ); }); I do not understand that code. The waitUntil method is documented too, and it seems the code above is the single purpose of it's existence at the moment: The ExtendableEvent.waitUntil() method extends the lifetime of the

What's the right way to implement offline fallback with workbox

放肆的年华 提交于 2019-12-03 08:37:32
I am implementing PWA into my project, I have setted up the serviceworker.js, and I am using workbox.js for cache routing and strategies. 1- I add the offline page to cache on install event, when a user first visit the site: /** * Add on install */ self.addEventListener('install', (event) => { const urls = ['/offline/']; const cacheName = workbox.core.cacheNames.runtime; event.waitUntil(caches.open(cacheName).then((cache) => cache.addAll(urls))) }); 2- Catch & cache pages with a specific regex, like these: https://website.com/posts/the-first-post https://website.com/posts/ https://website.com

WKWebView analog of service worker

為{幸葍}努か 提交于 2019-12-03 07:47:25
I'm trying to implement part of app with PWA approach, that works fine on Android , but not for iOS . We need to have offline content availability option to update content dynamically (like special offers or so). With service worker we show prompt to update web content. As were mentioned here service workers are not supported within WKWebView (or UIWebView ). So is there analog or alternative solution like smart cache control? Seems like it is possible to store some web content from app and be able to update it if something changes. May there is already a framework/library/approach for that

Service Worker vs Shared Worker

…衆ロ難τιáo~ 提交于 2019-12-03 06:34:36
问题 What is the difference between Service Worker and Shared Worker? When should I use Service Worker instead of Shared Worker and vice versa? 回答1: A service worker has additional functionality beyond what's available in shared workers, and once registered, they persist outside the lifespan of a given web page. Service workers can respond to message events, like shared workers, but they also have access to additional events. Handling fetch events allows service workers to intercept any network