I'm trying to implement an 'add to homescreen' banner using Google Chrome's native banner support, with this demo as reference.
https://googlechrome.github.io/samples/app-install-banner/basic-banner/index.html
According to the spec there, the requirements are:
The manifest I am using is below.
{
"name": "Web app test",
"short_name": "Test",
"icons": [
{
"src": "/resources/launcher-icon-3x.png",
"sizes": "144x144",
"type": "image/png"
}
],
"display": "standalone"
}
Which contains a short_name and a 144 pixel icon of type image/png.
The service worker I am using is a direct copy & paste of this code:
https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/custom-offline-page/service-worker.js
which was recommended in this article:
https://developers.google.com/web/updates/2015/03/increasing-engagement-with-app-install-banners-in-chrome-for-android?hl=en
The service worker has been registered, the manifest is being loaded into the page and the image url is correct, but the banner is not showing.
I also have the chrome://flags/#bypass-app-banner-engagement-checks enabled so this isn't a case of me needing to come back tomorrow and check that it works. I have been able to view homescreen banners on all of Chrome's demos that I have checked (which is where I took most of this code from) and my phone has the latest version of Chrome installed.
Is there anything else I am missing that could be blocking the homescreen banner from appearing?
Thanks.
A couple of things to check:
start_url
in your manifest that defines the page to launch.<link rel=manifest>
in your page Mounir Lamouri has created a manifest validator that you can use to check your manifest is correct.
You should also enable chrome://flags/#bypass-app-banner-engagement-checks if you are using Chrome so that you get a quicker warning or visibility of any issues. Finally you can look in the Dev Tools console on any page load and an error will be shown indicating why the banner wasn't shown.
There is also a lot of guidance on developers.google.com
background_color
and theme_color
.onbeforeinstallprompt
event.In general I'd recommend pasting your manifest into this to ensure it doesn't have any errors: http://mounirlamouri.github.io/manifest-validator/
If using Chrome with chrome://flags/#bypass-app-banner-engagement-checks enabled, you can look in the console on any page load and an error will be shown indicating why the banner wasn't shown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With