0

I am implementing the Push notifaication in my application with the help of Article = https://medium.com/@arjenbrandenburgh/angulars-pwa-swpush-and-swupdate-15a7e5c154ac

I am using Angular version7 and using => SwPush from '@angular/service-worker' for push notification in my App.

To run the application and see push notification functionality in my app, I use 2 commands:

  1. ng build --prod
  2. http-server -p4100 -c-1 dist/my-pwa-app

After running these 2 commands, the app shows: enter image description here

when i open http://localhost:4100 OR http://127.0.0.1:4100 the service worker is running and push notification is working.

But when i open http://172.16.0.201:4100 in the browser, there is no service worker running in the Application => Service worker

Er Vipin Sharma
  • 2,519
  • 8
  • 22
  • 32
  • Possible duplicate of [Options for testing service workers via HTTP](https://stackoverflow.com/questions/34160509/options-for-testing-service-workers-via-http) – abraham Sep 20 '19 at 21:08

1 Answers1

3

This is because Service Workers are restricted to HTTPS connections with excemptions for localhost and 127.0.0.1. In order to have SW working in 172.16.0.201 (or anything else than the localhost), you need to serve the page over HTTPS connection.

More information available here https://stackoverflow.com/a/34161385/5038943

pate
  • 4,937
  • 1
  • 19
  • 25