PWA работает в Google chrome, но не firefox - PullRequest
0 голосов
/ 07 августа 2020

Итак, я решил превратить свой тестовый веб-сайт в PWA, и он работает с Google chrome, но не firefox (мобильный).

Это есть в моем индексе . html голова

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <title>MYWEBSITE</title>

    <!--Website Icon-->
    <link rel="icon" type="image/svg+xml" href="images/favicon.svg">
    <link rel="alternate icon" href="images/favicon.png">

    <!--Stylesheets-->
    <link rel="stylesheet" href="css/style.css">

    <!--PWA-->
    <link rel="manifest" href="manifest.webmanifest">
    <script>
        if ('serviceWorker' in navigator) {
            navigator.serviceWorker.register('sw.js');
        };
    </script>
</head> 

Мой manifest.webmanifest

{
    "name": "Progressive Web App",
    "short_name": "Site",
    "description": "Stuff",
    "icons": [{
            "src": "/images/favicon.svg",
            "type": "image/svg+xml",
            "sizes": "192x192"
        },
        {
            "src": "/images/favicon.svg",
            "type": "image/svg+xml",
            "sizes": "512x512"
        },
        {
            "src": "icon/fox-icon.png",
            "sizes": "192x192",
            "type": "image/png"
        }
    ],
    "start_url": "index.html",
    "background_color": "#000000",
    "display": "standalone",
    "theme_color": "#91e7ee"
}

И sw. js

// On install - caching the application shell
self.addEventListener('install', function(event) {
    event.waitUntil(
        caches.open('sw-cache').then(function(cache) {
            // cache any static files that make up the application shell
            return cache.add('index.html');
        })
    );
});

// On network request
self.addEventListener('fetch', function(event) {
    event.respondWith(
        // Try the cache
        caches.match(event.request).then(function(response) {
            //If response found return it, else fetch again
            return response || fetch(event.request);
        })
    );
});

В мой код больше ничего не добавлено. Что еще мне не хватает? Потому что я искал и все должно, но это не так?

...