【问题标题】:progressive web app site cannot be installed: no icon available to display无法安装渐进式 Web 应用程序站点:没有可显示的图标
【发布时间】:2017-09-04 13:25:26
【问题描述】:

我正在构建一个渐进式网络应用程序。我从create-react-app 的样板开始。然后我添加了一个网络应用清单。

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"
}

将此链接到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>

我已经使用realfavicongenerator.net 生成了图标并将它们放在公共目录中。

我正在使用 gh-pages 部署我的应用程序。当我尝试 Add to homescreen 时,我收到以下错误

我认为我在 webmanifest 中为图标做错了什么。

【问题讨论】:

    标签: reactjs progressive-web-apps create-react-app web-manifest


    【解决方案1】:

    您的图标路径引用根目录。

    "src": "/android-chrome-192x192.png", 更改为"src": "android-chrome-192x192.png",(开头没有/)。

    【讨论】:

    • 在我的情况下,我忘记了发送中的binary 选项,nodejs,我必须这样做:https://stackoverflow.com/a/5826883/7173478 只是确保,伙计们,你们都在这样做
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-17
    • 1970-01-01
    • 2018-10-27
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多