Chrome Android 中带有 Web 应用程序清单的可安装 Web 应用程序无法正常工作
Installable Web Apps with the Web App Manifest in Chrome for Android not working
你好,我收到了这个错误:
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
这是我的 manifest.json:
{
"name": "SIMIC project",
"short_name": "simic",
"icons": [{
"src": "images/simic-bn.png",
"type": "image/png",
"sizes": "32x32"
},
{
"src": "images/simic-bn.png",
"type": "image/png",
"sizes": "144x144"
}],
"start_url": "/wta/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#1e88e5"
}
这是我的 url:"mydomain:8889/wta/" 这是我的代码结构:
-我的域名
---wta
------css/
------字体/
------图片/
------js/
------index.html
------manifest.json
我错过了什么?谢谢
您还需要一个 service worker 脚本来控制您的资产,offline-plugin 应该是个不错的选择!
为了让您的网络应用可安装/添加到主屏幕,您需要满足以下要求:
有一个包含 short_name
、name
、icon
和 start_url
的网络应用程序清单文件(您已经拥有)
服务人员
它必须通过 HTTPS 提供
目前您有网络应用程序清单文件,但您需要一个服务工作者。 Service Worker 基本上是一个 Javascript 文件,可以拦截网络请求、缓存您的资产、可以发送推送通知等。
您可以创建此 js 文件并像这样注册您的 service worker:
if ('serviceWorker' in navigator) {
// register the service worker
navigator.serviceWorker.register('service-worker.js')
.then(function(reg){
console.log("service worker registered");
}).catch(function(err) {
console.log("error: ", err)
});
}
请注意,这应该位于根文件夹中,以便它适用于整个站点。
你好,我收到了这个错误:
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
这是我的 manifest.json:
{
"name": "SIMIC project",
"short_name": "simic",
"icons": [{
"src": "images/simic-bn.png",
"type": "image/png",
"sizes": "32x32"
},
{
"src": "images/simic-bn.png",
"type": "image/png",
"sizes": "144x144"
}],
"start_url": "/wta/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#1e88e5"
}
这是我的 url:"mydomain:8889/wta/" 这是我的代码结构:
-我的域名
---wta
------css/
------字体/
------图片/
------js/
------index.html
------manifest.json
我错过了什么?谢谢
您还需要一个 service worker 脚本来控制您的资产,offline-plugin 应该是个不错的选择!
为了让您的网络应用可安装/添加到主屏幕,您需要满足以下要求:
有一个包含
short_name
、name
、icon
和start_url
的网络应用程序清单文件(您已经拥有)服务人员
它必须通过 HTTPS 提供
目前您有网络应用程序清单文件,但您需要一个服务工作者。 Service Worker 基本上是一个 Javascript 文件,可以拦截网络请求、缓存您的资产、可以发送推送通知等。
您可以创建此 js 文件并像这样注册您的 service worker:
if ('serviceWorker' in navigator) {
// register the service worker
navigator.serviceWorker.register('service-worker.js')
.then(function(reg){
console.log("service worker registered");
}).catch(function(err) {
console.log("error: ", err)
});
}
请注意,这应该位于根文件夹中,以便它适用于整个站点。