我想使添加到主屏幕旗帜,我的Asp.net项目 我Index.js是“添加到主屏幕”弹出窗口没有出现在我的ASP.Net网站
// Make sure we are accessing over https, if not redirect
if ((!location.port || location.port === "80") && location.protocol !== "https:" && location.host !== "localhost") {
location.protocol = "https:";
}
if (navigator.serviceWorker) {
navigator.serviceWorker.register('sw.js').then(function (registration) {
console.log('ServiceWorker registration successful with scope:', registration.scope);
}).catch(function (error) {
console.log('ServiceWorker registration failed:', error);
});
}
和我Sw.js是
console.log('I am a Service Worker!');
self.addEventListener('install', function() {
self.skipWaiting();
});
self.addEventListener('activate', function (event) {
event.waitUntil(clients.claim());
});
和我的清单文件就像
{
"name": "App_Name",
"short_name": "APP",
"icons": [
\t \t {
"src": "120x120.png",
"type": "image/png",
"sizes": "128x128"
},
\t {
"src": "152x152.png",
"type": "image/png",
"sizes": "152x152"
},
\t {
"src": "144x144.png",
"type": "image/png",
"sizes": "144x144"
},
\t {
"src": "192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "192x192.png",
"type": "image/png",
"sizes": "256x256"
},
{
"src": "192x192.png",
"type": "image/png",
"sizes": "512x512"
}
\t ],
"start_url": "Welcome.aspx?launcher=true",
"scope": "/",
"display": "standalone",
"orientation": "portrait",
"background_color": "#aac73c ",
"theme_color": "#63528a"
}
这作品时,点击“添加到主屏幕”的应用程序选项卡形式Devtool。但它不能像这样显示添加到主屏幕的Popup。
请指教...在此先感谢
已启用“通过用户参与检查”。从铬旗,我想我错过了我的编码中的一些步骤。 – TouchStarDev