8

I am start working with PWA (Progressive web app). When I try to check service worker is supported or not in chrome browser.It always return false. Below code I used for the checking.

Note: I am using chrome Version 69.0.3497.81 (Official Build) (64-bit).

app.js

if ('serviceWorker' in navigator) {
    navigator.serviceWorker.register('/sw.js').then(function() {
        console.log('service worker registered');
    });
}

Need help to register service worker in chrome.

baj9032
  • 2,414
  • 3
  • 22
  • 40

1 Answers1

25

This problem is cause due to I am running my application on http://192.168.1.11:8080 but when I switch domain to http://localhost:8080/. it's working fine.

Chrome requires service workers to be served over https, but allows an exception for localhost for development.

Peter Fernandes
  • 307
  • 1
  • 9
baj9032
  • 2,414
  • 3
  • 22
  • 40
  • 2
    For development purpose, you can also add your local non-secure http address to chrome to override. please refer this answer https://stackoverflow.com/a/54934302/3192693 – Monster Brain Mar 14 '19 at 05:40