Angular 6 - “Service workers are disabled or not supported” error

后端 未结 2 2037
眼角桃花
眼角桃花 2021-01-17 20:24

I want to push notification subscription with web-push module and angular service worker. I\'ve followed instructions from these links: Angular Pus

相关标签:
2条回答
  • 2021-01-17 20:46

    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

    0 讨论(0)
  • 2021-01-17 21:02

    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})
    
    0 讨论(0)
提交回复
热议问题