添加到主屏幕' Web应用安装横幅未显示在我的网络应用中并显示错误

时间:2017-07-03 13:00:24

标签: html5 google-chrome progressive-web-apps manifest.json

以下是我的manifest.json文件

{
    "short_name": "ponds.brandfans.co",
    "name": "ponds.brandfans.co",
    "icons": [{
        "src": "/images/logo/favicons/36x36.png",
        "sizes": "36x36",
        "type": "image/png",
        "density": "0.75"
    }, {
        "src": "/images/logo/favicons/36x36.png",
        "sizes": "48x48",
        "type": "image/png",
        "density": "1.0"
    }, {
        "src": "/images/logo/favicons/36x36.png",
        "sizes": "72x72",
        "type": "image/png",
        "density": "1.5"
    }, {
        "src": "/images/logo/favicons/36x36.png",
        "sizes": "96x96",
        "type": "image/png",
        "density": "2.0"
    }, {
        "src": "/images/logo/favicons/36x36.png",
        "sizes": "144x144",
        "type": "image/png",
        "density": "3.0"
    }, {
        "src": "/images/logo/favicons/36x36.png",
        "sizes": "192x192",
        "type": "image/png",
        "density": "4.0"
    }],
    "start_url": "/",
    "display": "standalone",
    "gcm_sender_id": "482941778795",
    "background_color": "#2c3e50",
    "theme_color": "#2c3e50"
}

我收到错误:"无法安装网站:该网页无法脱机工作" 如果我遗漏了什么,请告诉我?

2 个答案:

答案 0 :(得分:0)

有趣的是你问了这个问题。我正在渲染一个回答这个问题的视频:) https://youtu.be/xvLnmdjgEWY

您的服务人员需要一个获取事件处理程序。

答案 1 :(得分:0)

正如Chris Love的博客和视频所示,您必须将此添加到您的服务工作者javascript代码中:

self.addEventListener("fetch", function(event) {});

(对我来说,服务工作者文件(sw.js)只包含这一行)