1

Hello i'm getting this error:

Site cannot be installed: no matching service worker detected. You may need to reload the page, or check that the service worker for the current page also controls the start URL from the manifest

This is my manifest.json:

{
  "name": "SIMIC project",
  "short_name": "simic",
  "icons": [{
    "src": "images/simic-bn.png",
    "type": "image/png",
    "sizes": "32x32"
  },
  {
    "src": "images/simic-bn.png",
    "type": "image/png",
    "sizes": "144x144"
  }],
  "start_url": "/wta/",
  "display": "standalone",
  "background_color": "#ffffff",
  "theme_color": "#1e88e5"
}

This is my url: "mydomain:8889/wta/" and this is my code structure:

-mydomain

---wta

------css/

------font/

------images/

------js/

------index.html

------manifest.json

What am i missing? THX

2 Answers 2

7

In order for your web app to be installable / be added to the home screen, you need to meet the following requirements:

  1. have a web app manifest file with a short_name, a name, an icon and a start_url (which you already have)

  2. a service worker

  3. it must be served over HTTPS

Currently you have the web app manifest file, but you need a service worker. A service worker is basically a Javascript file that intercepts network requests, caches your assets, can send push notifications, etc.

You can create this js file and register your service worker like so:

if ('serviceWorker' in navigator) {
    // register the service worker
    navigator.serviceWorker.register('service-worker.js')
        .then(function(reg){
            console.log("service worker registered");
        }).catch(function(err) {
            console.log("error: ", err)
        });
}

Note that this should be in the root folder for it to work for the entire site.

Sign up to request clarification or add additional context in comments.

2 Comments

thaks for your answer! I understand what you say, but what do i have to write in my service worker? The code you wrote is just a js file pointing to service worker, isn't it? What does "service-worker.js" contains?
i followed this link: codelabs.developers.google.com/codelabs/add-to-home-screen/#5 ....i added this: "self.addEventListener('fetch', function(event) { });" in my service work file. It works fine!
0

You also need a service worker script to control your assets, offline-plugin should be a great option!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.