I'm building a progressive web app. I started off with boilerplate from create-react-app. Then I added a web app manifest.
app/public/manifest.json
{
"short_name": "First Contributions",
"name": "First Contributions",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-256x256.png",
"sizes": "256x256",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone",
"start_url": "index.html"
}
Linked this to index.html
app/public/index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<title>First Contributions</title>
</head>
<body>
<div id="root"></div>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js').catch(function(ex) {
console.warn(ex);
console.warn('(This warning can be safely ignored outside of the production build.)');
});
}
</script>
</body>
</html>
I've generated icons using realfavicongenerator.net
and put them in public directory.
I'm deploying my app using gh-pages
. When I try to Add to homescreen
, I get the following errors
- android-chrome-192x192.png:1 GET https://roshanjossey.github.io/android-chrome-192x192.png 404 (Not Found)
- Error while trying to use the following icon from the Manifest: https://roshanjossey.github.io/android-chrome-192x192.png (Download error or resource isn't a valid image)
- Site cannot be installed: no icon available to display
I think I'm doing something wrong in webmanifest for icons.
Your icon paths reference to root directory.
Change
"src": "/android-chrome-192x192.png",
to"src": "android-chrome-192x192.png",
(without/
at the beginning).