I want to push notification subscription with web-push
module and angular service worker
. I\'ve followed instructions from these links: Angular Pus
This error was caused due to the reason that service workers don't work with ng serve
. Run with http-server
then it works fine.
As in Angular service workers said:
Because ng serve does not work with service workers, you must use a separate HTTP server to test your project locally. You can use any HTTP server
Just set the service worker to work in dev environment also in 'AppModule'
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production})
To
ServiceWorkerModule.register('ngsw-worker.js', { enabled: true})