【问题标题】:Android Smart Banner -- Manifest for Native App Install Complains About Missing Service WorkersAndroid 智能横幅——原生应用安装清单抱怨缺少服务人员
【发布时间】:2017-10-12 16:23:24
【问题描述】:

我已经阅读了 Google 的文档,四处搜索并查看了 Stack Overflow,但没有找到任何解决此问题的方法。

我需要一个 Android 智能横幅来为网站安装本机应用程序,因此(根据 Google 的说明)创建了以下清单(出于隐私原因删除了详细信息):

{
  "short_name": "ShortName",
  "name": "Longer App Name",
  "start_url": ".",
  "display": "standalone",
  "icons": [
    {
         "src": "icon.png",
         "type": "image/png",
         "sizes": "144x144"
     }
  ],
  "prefer_related_applications": true,
  "related_applications": [
    {
         "platform": "play",
         "id": "com.app.name"
    }
  ]
}

由于这是一个原生应用程序,它不需要任何服务人员,according to Google's guidelines。但是,当我打开网站并尝试添加到主屏幕(通过开发者控制台)时,我不断收到以下错误:

无法安装站点:未检测到匹配的服务人员。你 可能需要重新加载页面,或者检查服务工作者 当前页面还控制清单中的起始 URL。

你知道为什么会这样吗?看起来这不是原生应用安装,但它为什么会这样认为呢?

我从一开始就注意到了一些可疑的事情,比如它抱怨我没有 start_url 和 display,尽管指南没有提到它对于原生应用程序是必需的。

你能告诉我我做错了什么吗?

谢谢!

【问题讨论】:

    标签: android web mobile android-manifest


    【解决方案1】:

    阅读google documentation我只能看到一些差异,我会放在这里以便您检查:

    • Png 图标大小应为 192x192
    • 我会删除“start_url”和“display”
    • 在两周的过程中,用户在两个不同的日子里访问了两次。 (这也可能很重要)

    【讨论】:

      【解决方案2】:

      Service Worker 只是针对 PWA 的警告。对于原生应用程序,这可以忽略。

      docs 中缺少一个标准:需要多个不同的图标大小。这些尺寸是36x3648x4872x7296x96144x144192x192

      这是一个例子:

      {
        "name": "App Name",
        "short_name": "App Name Install Banner Sample",
        "icons": [
          {
            "src": "icon-0-75x.png",
            "sizes": "36x36",
            "type": "image/png"
          },
          {
            "src": "icon-1x.png",
            "sizes": "48x48",
            "type": "image/png"
          },
          {
            "src": "icon-1-5x.png",
            "sizes": "72x72",
            "type": "image/png"
          },
          {
            "src": "icon-2x.png",
            "sizes": "96x96",
            "type": "image/png"
          },
          {
            "src": "icon-3x.png",
            "sizes": "144x144",
            "type": "image/png"
          },
          {
            "src": "icon-4x.png",
            "sizes": "192x192",
            "type": "image/png"
          }
        ],
        "prefer_related_applications": true,
        "related_applications": [
          {
            "platform": "play",
            "id": "com.google.samples.apps.iosched",
            "url": "https://play.google.com/store/apps/details?id=com.google.samples.apps.iosched"
          }
        ],
        "start_url": ".",
        "display": "standalone"
      }
      

      提醒一下:

      1. 在 chrome 中启用此标志 chrome://flags/#bypass-app-banner-engagement-checks
      2. 在您的 Android 设备或模拟器上登录 Google Play(确保模拟器具有 Play 商店)
      3. 该应用不应已安装在设备上
      4. 关注requirements listed at the top here
      5. 检查浏览器中的源选项卡以查看清单是否正确提供,并记得检查控制台是否有任何错误(警告很好)

      【讨论】:

        猜你喜欢
        • 2017-02-19
        • 1970-01-01
        • 2019-04-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多