Bonjour,
J'aimerai rendre ma page HTML installable, mais mon fichier manifest n'est pas reconnu...
Voici mon fichier manifest.webmanifest :
{
"short_name": "PWA1",
"name": "My PWA 1st Prototype",
"icons": [
{
"src": "/images/icons-192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/images/icons-512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "/index.html",
"background_color": "#000000",
"display": "standalone",
"theme_color": "#ff0000"
}
Voici maintenant mon 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);
})
);
});
Et enfin ma page index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>My First PWA</title>
<meta name="theme-color" content="#ff0000"/>
<link rel="manifest" href="/manifest.webmanifest">
<script>
//if browser support service worker
if('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js');
};
</script>
</head>
<body>
<h1>PWA</h1>
<p>Hello world!</p>
</body>
</html>
J'ai l'impression que mon manifest est correctement lié, mais chrome me donne l'erreur "No manifest was fetched" dans Lighthouse...
Je dois savoir installer une PWA pour mon rattrapage de mardi...
Avez-vous une idée svp?
Je remercie par avance ceux qui pourront m'aider :)