Kuestenschmiede / PwaBundle

Adds PWA functionality to a contao application.
https://con4gis.org
9 stars 1 forks source link

No matching service worker detected #1

Closed hoaxone closed 5 years ago

hoaxone commented 5 years ago

Hi,

ich habe die Installation vorgenommen, die PWA-Einstellungen getätigt und die Module eingefügt. Ich bekomme die Fehlermeldung "No matching service worker detected".

Das Manifest sieht wie folgt aus:

{
    "dir": "ltr",
    "lang": "de-DE",
    "name": "PWA",
    "short_name": "PWA",
    "description": "PWA",
    "scope": "\/home.html",
    "start_url": "\/home.html",
    "display": "fullscreen",
    "background_color": "#000",
    "theme_color": "#000",
    "icons": [
        {
            "src": "files\/img\/icon_192.png",
            "sizes": "192x192",
            "type": "image\/png"
        },
        {
            "src": "files\/img\/icon_512.png",
            "sizes": "512x512",
            "type": "image\/png"
        }
    ],
    "serviceworker": {
        "src": "\/sw.js",
        "scope": ".",
        "update_via_cache": "none"
    }
}

Die erzeugte ws.js im root sieht wie folgt aus:

self.addEventListener('install', function(event) {
    event.waitUntil(
    caches.open('pwa-con4gis-v13').then(cache => 
        cache.addAll(['/',
        'manifest.webmanifest',
        'home.html',
    ])  ).then(() => self.skipWaiting()));
});
self.addEventListener('fetch', event => {
  if (event.request.mode === 'navigate') {

    return event.respondWith(
      fetch(event.request).catch(() => caches.match('home.html'))
    );
  }
});
self.addEventListener('push', event => {
  const notification = event.data.json();
  self.registration.showNotification(notification.title, {
    body: notification.body,
    icon: notification.icon,
    badge: notification.badge,
    image: notification.image,
    vibrate: [1000, 2000, 1000]
  });
});self.addEventListener('notificationclick', event => {
  event.notification.close();
  event.waitUntil(
    clients.matchAll().then(
      windowClients => {
        windowClients.length ? windowClients[0].focus() : clients.openWindow('/')
      }
    )
  );
});
hoaxone commented 5 years ago

Das Problem ist behoben. Ich hatte der Seite kein https Zertifikat zugeordnet.