service-worker

Uncaught (in promise) TypeError: Request failed pwa error

末鹿安然 提交于 2019-12-03 21:58:56
I am trying to build a Progressive Web App (PWA). The service worker shows registered, PWA audit shows everything good, but the console shows this error: TypeError: Request failed pwa error I am unable to cache the files. I tried all possible answers on Stack Overflow and it's the same //self.addEventListener('fetch', function(event) {}); var dataCacheName = 'myappData-v3n'; var cacheName = 'myapp-3n'; var filesToCache = [ 'images/logo.png', 'js/jquery.min.js', 'js/popper.min.js', 'js/bootstrap.min.js', 'js/main.js', 'css/bootstrap.min.css', 'css/fontawesome-all.min.css', 'css/style.css', 'css

Using sw-precache with client-side URL routes for a single page app

房东的猫 提交于 2019-12-03 16:16:10
How would one configure sw-precache to serve index.html for multiple dynamic routes? This is for an Angular app that has index.html as the entry point. The current setup allows the app to be accessable offline only through / . So if a user go to /articles/list/popular as an entry point while offline they won't be able to browse it and would be given you're offline message. (although when online they'd be served the same index.html file on all requests as an entry point) Can dynamicUrlToDependencies be used to do this? Or does this need to be handled by writing a separate SW script? Something

Request headers not sent from Service Worker

耗尽温柔 提交于 2019-12-03 15:55:12
I'm trying to fetch a web service from a Service Worker. This service is a JSP secured with basic Apache authentication, so I must provide the credentials to authenticate in the request headers. The following request works just fine from the main window: self.addEventListener('push', function(event) { console.log('Received a push message', event); event.waitUntil( fetch(ONLINE_SITE_ENDPOINT, { method: 'GET', mode: 'cors', headers: { 'Accept': 'application/json', 'Authorization': 'Basic btoa(auth info)' } }).then(function(response) { //process response }).catch(function(err) { }) ); }); That

Angular 7 - service worker not registered

跟風遠走 提交于 2019-12-03 15:43:32
问题 I did everything as written in "https://angular.io/guide/service-worker-getting-started" to make my application PWA. Used exactly this commands: ng add @angular/pwa npm install http-server -g ng build --prod http-server -p 8080 -c-1 dist Then I opened this url on Chrome (in incognito) http://127.0.0.1:8080 When I open tools for developers (f12) > Applications > Service Workers there is no service worker available and website don't work when I set offline there. Additional info about my

Service worker throwing an net::ERR_FILE_EXISTS error?

耗尽温柔 提交于 2019-12-03 14:20:46
问题 service-worker.js:1 GET http://localhost:8080/service-worker.js net::ERR_FILE_EXISTS This is the error I get every time I refresh after registering a service worker. I've made sure that the service-worker.js file exists in the root directory. Also the service worker is registered and working fine. But I still keep getting this error. Also I'm working on localhost. This is my service-worker.js file: console.log("SW startup"); var CACHE_NAME = "my_cache"; var urlsToCache = [ './', './css/style

PushManager subscription promise never fulfill nor reject

人走茶凉 提交于 2019-12-03 13:57:28
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+ version, the issue appears with older releases. (I'm using Chromium continuous builds to test the

How to add analytics for Push notifications

♀尐吖头ヾ 提交于 2019-12-03 13:48:16
问题 I'm working on progressive web app, and I want to implement analytics for Push notifications. How can I add analytics for push notifications so that I'll be able to track and record how many people clicked on notification and how many people close that notification without clicking on it. 回答1: I've written a small chunk of code to use Google analytics for analytics and it works fairly well. Dumped notes here: https://gauntface.com/blog/2016/05/01/push-debugging-analytics The way I've done

Firefox: Service Worker: SecurityError: DOMException: The Operation is insecure

ⅰ亾dé卋堺 提交于 2019-12-03 13:32:31
In app.js , I am checking the serviceWorker existence in navigator object and if available then registering the SW. if ('serviceWorker' in navigator) { navigator.serviceWorker.register('./service-worker.js', { scope: './' }) .then(function(registration) { console.log("Service Worker Registered!"); }).catch(function(err) { console.log("Service Worker not registered!", err); }); } When trying to register SW, I receive the below error in Firefox. I also made sure the service-worker.js file is under src directory. Checking my about:config in Firefox (version 59.0.2) I had service worker and

Update Service Worker in Facebook Browser

為{幸葍}努か 提交于 2019-12-03 13:31:30
问题 Got a problem where some of our users have a buggy Service Worker sitting in their Facebook Browsers from our sites. The problem: Facebook App users are getting our 'you are offline page' on the FB browser when they access our pages shared on FB. The bug appeared to be that an old version of Google's Workbox (3.6.1) was automatically returning the 'You Are Offline' page in the FB app using Chrome 75. Updating Workbox fixed it. The reference to Workbox was in the service worker, so when we

GCM registration id in Service Worker in Push Notification for chrome

百般思念 提交于 2019-12-03 12:42:50
问题 I am able to send push notification and in service worker i am making a service call i just to want to send GCM registration id with that service call. How to get registration id or subscription id in service worker here is my code self.addEventListener('push', function(event) { console.log('Received a push message from local', event); var title = 'My title file. Testing on'; var body = 'New Push Message.'; var icon = 'refresh_blueicon.png'; var tag = 'my-push-tag'; event.waitUntil( // Here i