angular-service-worker

Angular service worker with @angular/pwa package showing `HTTP error 504` when offline

别来无恙 提交于 2020-06-16 03:23:51
问题 I am working on an angular PWA application. So I added an npm package by ng add @angular/pwa . It is added successfully with no errors. The generated Manifest is working fine. But I am facing issues with the service worker. When the application goes online it stores all the caches (see attachment) but whenever the application goes offline, instead of serving the request from the service worker it shows the error - HTTP ERROR 504 Here is my ngsw-config.json - { "index": "/index.html",

How to run service worker locally with Angular

…衆ロ難τιáo~ 提交于 2020-06-12 09:02:46
问题 I am following angular's best practice in order to make PWA. After making production build ( ng build --prod --aot ), I am also running the service worker from dist, on localhost : http-server -p 8080 -c-1 dist When I am trying to sync the worker with my Angular, using: navigator.serviceWorker.ready.then(function(swRegistration) { console.log('swReady'); }); Nothing happens, and seems that SW is not communicating with Angular. Working with a remote server (uploading dist) does work. So seems

Angular5 PWA doesn't refresh (Service Workers)

一世执手 提交于 2020-05-15 04:46:25
问题 I'm developing an app with angular5, using service workers via the ng-cli, but I realized that after the first time the app shell loads, it doesn't refresh. How can I push new file versions to my app after build it with ng build ?. I could directly rewrite the sw.js manually, but as it is generated via the cli, I don't like to affect anything I don't know what is for. I'm looking for this answer all day, but as service workers are new for the 1.6 version of the ng-cli, I have not found any. I

Angular: Using TypeScript for Service Worker (ServiceWorkerModule)

99封情书 提交于 2020-01-25 06:55:10
问题 Is it possible to register a ServiceWorker written in TypeScript with @angular/service-worker ? currently registering a service worker looks like this in app.module.ts : ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }) Is it somehow possible to register a ngsw-worker.ts ? At least this is possible with web workers in Angular: const worker = new Worker('../my-worker.worker', { type: 'module' }); my-worker.worker.ts /// <reference lib="webworker" /> import

Angular5 Service Worker update(SWUpdate) not detecting on firefox. Working on chrome

寵の児 提交于 2020-01-14 07:40:43
问题 I am using Angular5 and angular service worker . I cached some data and some assets and everything is working fine as expected and even deployed the code. Now, if I update some code and deploy again, the service worker doesnot get updated. So, I had gone through Angular service worker link and I Implemened SwUpdate service . Here is my code: I created a service and called it in App Component import { Injectable, NgZone } from '@angular/core'; import { interval } from 'rxjs/observable/interval

Angular - is it ok to register ngsw-worker.js twice (in main.ts & app.module.ts)?

独自空忆成欢 提交于 2020-01-13 10:23:09
问题 I am registering ngsw-worker.js in both main.ts and app.module.ts. Is this ok? Such as would it create 2 instances of service worker? Would there be a conflict in service worker? main.ts platformBrowserDynamic().bootstrapModule(AppModule).then(() => { if ('serviceWorker' in navigator && environment.production) { navigator.serviceWorker.register('/ngsw-worker.js'); } }).catch(err => console.log(err)); app.module.ts @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule,

PWA loses its params and query params after being added to the home screen

空扰寡人 提交于 2020-01-04 03:51:43
问题 I have created a PWA(Progressive Web App) using Angular6. It works perfectly as expected in the browser. My scenario is to handle all the app data based on the params I get from URL eg: https://<my-site.com>/app/abc123 where abc123 is my param which I need to add to the home screen app. So the problem is when user adds the app to the home screen it loses all the params (I have tried using queryparams as well) and that leaves me only with the hostname. I need the whole URL to be added as the

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

Angular6 Service Worker and background sync

陌路散爱 提交于 2019-12-30 06:18:07
问题 it seems that angular6 does not support background syncing with service worker. What are the steps required to do this without any library in an angular service? https://developers.google.com/web/updates/2015/12/background-sync How and where can I access WorkerGlobalScope in an angular6 application directly so that background sync can be done.: self.addEventListener('sync', function(event) { if (event.tag == 'myFirstSync') { event.waitUntil(doSomeStuff()); } }); The problem is that the

Angular 6 : DevTools failed to parse SourceMap: https://example.com/ngsw_worker.es6.js.map

谁说胖子不能爱 提交于 2019-12-23 03:47:05
问题 I converted my angular 6 application to PWA using the Angular CLI (ng add @angular/pwa). I only have one project in my directory and so I ran this command without specifying project name. After deployment, the service worker registers - and everything seems to be in order expect i get the following error in google chrome console: DevTools failed to parse SourceMap: https://example.com/ngsw_worker.es6.js.map What does this error mean? And how can it be fixed/avoided? Thank you! 回答1: Go to