我的网站托管在 https 上。它有一个 manifest.json 文件、service-worker.js 和 SW 注册码。但我没有看到来自手机的添加到主屏幕弹出窗口。为什么?这是 index.html 文件:
<!DOCTYPE html public "display of affection from creativejs">
<html>
<head>
<meta charset="uft-8" /> <meta name="theme-color" content="#536878" /> <meta name=viewport content="width=device-width, initial-scale=1"> <title>Fireworks!</title>
<link rel="manifest" href="manifest.json"> </head>
<body>
<h1>Welcome!</h1>
</body>
<script>
if ('serviceWorker' in navigator) {
console.log("Will service worker register?");
navigator.serviceWorker.register('service-worker.js').then(function(reg){
console.log("Yes it did.");
}).catch(function(err) {
console.log("No it didn't. This happened: ", err)
});
}
</script>
</html>