Install web application

I use this page: https://developers.google.com/web/fundamentals/engage-and-retain/app-install-banners/ to create a web application banner installation.

I have sw.js as a service worker in public / admin / I have successfully registered a service worker and I have manifest.json in public / admin too like this

{ "name": "Web App Install", "short_name": "Admin", "icons": [ { "src": "/admin/mstile-70x70.png", "sizes": "36x36", "type": "image/png" }, { "src": "/admin/mstile-70x70.png", "sizes": "48x48", "type": "image/png" }, { "src": "/admin/mstile-70x70.png", "sizes": "72x72", "type": "image/png" }, { "src": "/admin/mstile-70x70.png", "sizes": "96x96", "type": "image/png" }, { "src": "/admin/mstile-70x70.png", "sizes": "144x144", "type": "image/png" }, { "src": "/admin/mstile-70x70.png", "sizes": "192x192", "type": "image/png" } ], "start_url": ".", "display": "standalone", "related_applications": [{ "platform": "web" }], "related_applications": [], "prefer_related_applications": false } 

in developer tools

service worker link: https: //01f1c2fb.ngrok/admin/pt

link manifest.json https: //01f1c2fb.ngrok/admin/manifest.json

but I get an error when trying to install a web application error

"The site cannot be installed: the corresponding service employee was not found. You may need to reload the page or check that the working service for the current page also controls the start URL from the manifest"

Can someone help me.

I add the / pt folder to admin as admin / pt and added manifest.json. I got some image errors when I clicked the “add to desktop” button, but I fixed it but now, by clicking “add to desktop”, it doesn’t start anything ... is all this good now?

I tried a mobile phone, but did not install ... can someone help thanks to Carlos Vieira

I have already made some changes, and I get "beforeinstallprompt Event Fired" in the console using

 window.addEventListener('beforeinstallprompt', function(e) { console.log('beforeinstallprompt Event fired'); }); 

but the application is not installed on the mobile device

Thanks in advance. Carlos Vieira

0
source share
1 answer

I had a similar problem.

You have a sw.js file in public / admin / , this is wrong. Move it to the root directory of / , and serviceWorker should start fine.

+2
source

Source: https://habr.com/ru/post/1270634/


All Articles