For add Native Banner in android device, I tried to add in my web app, manifest json and js code as documentation: https://developers.google.com/web/fundamentals/app-install-banners/native#criteria
I have two question because I'm confused,
Does the native banner only work with PWAs or can it also be inserted into a non-PWA web app? Is required to add a service worker? Thanks Manifest:
{
prefer_related_applications: true,
related_applications: [
{
platform: "play",
id: "name",
url: "url my app"
}
],
name: "name",
short_name: "name",
display: "standalone",
icons: [
{
src: "/images/icons/android-chrome-144x144.png?v=20211026145646",
sizes: "144x144",
type: "image/png"
},
{
src: "/images/icons/android-chrome-36x36.png?v=20211026145646",
sizes: "36x36",
type: "image/png"
},
{
src: "/images/icons/android-chrome-192x192.png?v=20211026145646",
sizes: "192x192",
type: "image/png"
},
{
src: "/images/icons/android-chrome-48x48.png?v=20211026145646",
sizes: "48x48",
type: "image/png"
},
{
src: "/images/icons/android-chrome-72x72.png?v=20211026145646",
sizes: "72x72",
type: "image/png"
},
{
src: "/images/icons/android-chrome-96x96.png?v=20211026145646",
sizes: "96x96",
type: "image/png"
},
{
src: "/images/icons/favicon-android-512x512.png?v=20211026145646",
sizes: "512x512",
type: "image/png"
}
],
background_color: "#131822",
start_url: "."
}
App.js
window.addEventListener('load', function() {
console.log('SONO QUI');
var outputElement = document.getElementById('output');
window.addEventListener('beforeinstallprompt', function(e) {
console.log('OPPURE QUI');
outputElement.textContent = 'beforeinstallprompt Event fired';
});
});