service-worker

NullInjectorError: No provider for SwUpdate! SwUpdate does not work Angular 5

吃可爱长大的小学妹 提交于 2019-12-05 09:43:38
Now I know there are a million posts about No Provider for such and such service, I know it needs to go in the providers please read my entire post. Basically I am trying to use SwUpdate to check to see if there is an update if so, refresh the browser: import { SwUpdate } from '@angular/service-worker'; ... export class ... constructor( private _swUp: SwUpdate ){} ngOnInit() { this.checkForUpdate(); } checkForUpdate() { if (this._swUp.isEnabled) { this._swUp.available .subscribe(() => { window.location.reload(); }); } } now I have registered my serviceworker: import { ServiceWorkerModule }

Is it possible to track geolocation with a service worker while PWA is not open

走远了吗. 提交于 2019-12-05 08:21:49
Is it possible to read from local storage and track geolocation in PWAs with a service worker while app is not open on phone (in background) So far my research is pointing to no, and I am finding that the PWA needs to be open for location services. Thank you, The solution is at hand and has been for some years now as this POC clearly testifies. Unfortunately W3C and lobbyists such as Jake Archibald have fought tooth and nail to prevent it from being made available :-( Why? I know not. The "cui bono" argument points to plug-in vendors such as Ionic whose whole raison d'etre appears to be

How can I customize my Service Worker based on environment variables?

纵然是瞬间 提交于 2019-12-05 05:29:47
Edit: This looks like a duplicate of this Unresolved Question . Do I mark this as answered, or delete? I am using InjectManifest from workbox-webpack-plugin inside a Vue CLI 3 app. The custom service worker that I am injecting into has handling for Firebase Cloud Messaging (FCM). I need to listen for messages from different senders based on my environment (local, staging, and production). Ideally, service-worker.js would look like this: importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-app.js'); importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-messaging.js');

Strategy for Push notifications on Safari

喜你入骨 提交于 2019-12-05 05:25:10
I am working on implementing a PWA which needs to send push notifications, we are looking at a solution for sending push notifications to browsers running on ios(We are using Firebase(FCM) for everything else.) What would be a good strategy to make push notifications on all platforms including ios? We are looking at sniffing the user-agent and use FCM for non-ios users, switch to websockets for ios users. We aren't sure how viable this approach is gonna be. Any suggestions on this approach or a better alternative would be of great help! It looks like you can treat Safari like an APNS device:

Why does fetch request have to be cloned in service worker?

雨燕双飞 提交于 2019-12-05 02:27:08
In one of the Service Worker examples by Google, cache and return requests self.addEventListener('fetch', function(event) { event.respondWith( caches.match(event.request) .then(function(response) { // Cache hit - return response if (response) { return response; } // IMPORTANT: Clone the request. A request is a stream and // can only be consumed once. Since we are consuming this // once by cache and once by the browser for fetch, we need // to clone the response. var fetchRequest = event.request.clone(); return fetch(fetchRequest).then( function(response) { // Check if we received a valid

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

♀尐吖头ヾ 提交于 2019-12-05 01:32:54
问题 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

Service Worker support in chrome webview

元气小坏坏 提交于 2019-12-05 01:30:59
Is Service Worker supported in chrome webview for android, if yes then from which version is it supported. Tried googling, but didn't find proper information. As per this announcement , service workers have been supported in Chrome WebViews since March of 2015 (Android WebView v40+). Devices running Android OS 5.0 and higher should have it. Since WebViews have their own sandboxed environment, the data cached by a service worker there won't be exposed to the normal Chrome application, and vice versa. If you were using Chrome Custom Tabs , the cached data would be shared with the normal Chrome

How does global error handling work in service workers?

一世执手 提交于 2019-12-05 01:09:19
I found https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/onerror which says: The onerror property of the ServiceWorkerContainer interface is an event handler fired whenever an error event occurs in the associated service workers. However I'm not able to get this working in Chrome (v51). In the scope of the main application, I ran the following code from the console: navigator.serviceWorker.onerror = function(e) { console.log('some identifiable string' + e); }; Then within the scope of the active service worker I triggered an arbitrary error: f(); // f is undefined The

Manifest start_url is not cached by a Service Worker

孤者浪人 提交于 2019-12-05 00:54:08
I'm using Lighthouse to audit my webapp. I'm working through the failures, but I'm stuck on this one: Failures: Manifest start_url is not cached by a Service Worker. In my manifest.json I have "start_url": "index.html", In my worker.js I am caching the following: let CACHE_NAME = 'my-site-cache-v1'; let urlsToCache = [ '/', '/scripts/app.js', '/index.html' ]; Which lines up with what I see in the Application tab in Chrome Dev tools: So... why is it telling me start_url is not cached? Here is my full worker.js file: if ('serviceWorker' in navigator) { window.addEventListener('load', function()

Angular 5 Service Worker not working

拈花ヽ惹草 提交于 2019-12-05 00:20:09
I try to add service worker to my project after updating to angular 5 and have some problems. I add imports to app.module.ts: import {ServiceWorkerModule} from '@angular/service-worker'; import {environment} from '../environments/environment'; ... environment.production ? ServiceWorkerModule.register('/ngsw-worker.js') : [], execute $ ng set apps.0.serviceWorker=true to allow service workers in project generate config: { "index": "/index.html", "assetGroups": [ { "name": "app", "installMode": "prefetch", "resources": { "files": [ "/index.html" ], "versionedFiles": [ "/*.bundle.css", "/*.bundle