Я пытаюсь сделать баннер «Добавить на главный экран» с моим проектом Asp.net. Мой Index.js
// 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": [
{
"src": "120x120.png",
"type": "image/png",
"sizes": "128x128"
},
{
"src": "152x152.png",
"type": "image/png",
"sizes": "152x152"
},
{
"src": "144x144.png",
"type": "image/png",
"sizes": "144x144"
},
{
"src": "192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "192x192.png",
"type": "image/png",
"sizes": "256x256"
},
{
"src": "192x192.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "Welcome.aspx?launcher=true",
"scope": "/",
"display": "standalone",
"orientation": "portrait",
"background_color": "#aac73c ",
"theme_color": "#63528a"
}
Это работает, когда вы нажимаете «Добавить на главный экран» в форме Devtool на вкладке «Приложение». но он не может отображать всплывающее окно добавления на главный экран, как это.
пожалуйста, сообщите... Заранее спасибо