Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service worker is not supported in chrome (69.0.3497.81)

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.

like image 496
baj9032 Avatar asked Sep 11 '18 06:09

baj9032


People also ask

Do service workers work on all browsers?

From what I understand, service workers do not work on all browsers, but I checked to see if it runs in Chrome (which is what I'm testing in) and it says that service workers are supported. Can someone please tell me why it isn't working?

Why can't service workers access the DOM parser?

Since service workers don't have access to DOM, it's not possible for an extension's service worker to access the DOMParser API or create an <iframe> to parse and traverse documents. Extension developers have two ways to work around this limitation: create a new tab or use a library. Which you choose will depend on your use case.

Why do service workers require that my site be served over HTTPS?

In short: Service workers requires the site using them to be served over HTTPS for security reasons, but have execptions for localhost. Check this for how to serve your html file on localhost.

What is a service worker?

Service workers are a specialized kind of web worker, which are quite different from the web pages most web developers are used to working with. On a typical web page (or extension background page), the global execution context for JavaScript is of type Window.


1 Answers

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.

like image 177
baj9032 Avatar answered Nov 23 '22 17:11

baj9032