网络应用横幅安装 [英] web app banner install

查看:20
本文介绍了网络应用横幅安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此页面:https://developers.google.com/web/fundamentals/engage-and-retain/app-install-banners/ 以创建网络应用横幅安装.

I'm using this page: https://developers.google.com/web/fundamentals/engage-and-retain/app-install-banners/ to create a web app banner install.

我在 public/admin/中有 sw.js 作为 service worker我已经成功注册了 service worker我也像这样在 public/admin 中有 manifest.json

I have the sw.js as service worker in public/admin/ I have registered with success the service worker and i have the manifest.json in public/admin too like this

{
  "name": "Web App Install",
  "short_name": "Admin",
  "icons": [
    {
      "src": "/admin/mstile-70x70.png",
      "sizes": "36x36",
      "type": "image/png"
    },
    {
      "src": "/admin/mstile-70x70.png",
      "sizes": "48x48",
      "type": "image/png"
    },
    {
      "src": "/admin/mstile-70x70.png",
      "sizes": "72x72",
      "type": "image/png"
    },
    {
      "src": "/admin/mstile-70x70.png",
      "sizes": "96x96",
      "type": "image/png"
    },
    {
      "src": "/admin/mstile-70x70.png",
      "sizes": "144x144",
      "type": "image/png"
    },
    {
      "src": "/admin/mstile-70x70.png",
      "sizes": "192x192",
      "type": "image/png"
    }
  ],
  "start_url": ".",
  "display": "standalone",
  "related_applications": [{
            "platform": "web"
        }],
    "related_applications": [],
    "prefer_related_applications": false
}

在开发工具中

service worker 的链接是:https://01f1c2fb.ngrok/admin/pt

the link of service worker is: https://01f1c2fb.ngrok/admin/pt

manifest.json 的链接是 https://01f1c2fb.ngrok/admin/manifest.json

the link of manifest.json is https://01f1c2fb.ngrok/admin/manifest.json

但是我在尝试安装 Web 应用程序时遇到错误错误是

but i'm getting an error on trying install the web app the error is

站点无法安装:未检测到匹配的 Service Worker.您可能需要重新加载页面,或检查当前页面的 Service Worker 是否还控制清单中的起始 URL"

"Site cannot be installed: no matching service worker detected. You may need to reload the page, or check that the service worker for the current page also controls the start URL from the manifest"

有人可以帮我吗.

我在 admin 中添加一个文件夹/pt 为 admin/pt并添加了 manifest.json.当我点击添加到主屏幕"时,我得到了一些图像错误,但我修复了它但现在点击添加到主屏幕"他没有触发任何东西......现在还好吗?

i add a folder /pt in admin as admin/pt and added the manifest.json. i got some errors of image when i clicked to "add to homescreen" but i fixed it but now clicking on "add to homescreen" he doesnt fire anything... its all alright for now ?

我试过手机但没有安装...有人可以帮忙吗谢谢卡洛斯·维埃拉

i tried i mobile phone but not installing ... can someone help thanks Carlos Vieira

我已经做了一些改变,我明白了使用

i already have made some changes and i get "beforeinstallprompt Event fired" in console using

window.addEventListener('beforeinstallprompt', function(e) {
          console.log('beforeinstallprompt Event fired');

        });

但没有安装手机应用

提前致谢.卡洛斯·维埃拉

Thanks in advance. Carlos Vieira

推荐答案

我遇到了类似的问题.

您在 public/admin/ 中有 sw.js 文件,这是错误的.将其移动到根目录/ 并且 serviceWorker 应该可以正常初始化.

You have your sw.js file in public/admin/, this is wrong. Move it to root directory / and serviceWorker should init fine.

这篇关于网络应用横幅安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆