Chrome 76 has introduced a button in the omnibox to "Install App" if the PWA criteria is met.
Is there a way to prevent this button from appearing in the omnibox for chrome desktop?
With a PWA, you can use a single codebase that's shared between your website, mobile app, and desktop app (across operating systems).
You can use Progressive Web Apps (PWAs) for a fast web experience on your computer or mobile device. You can install the PWA for faster access and additional functionality, like more storage for content to use offline.
The browser's installation prompts are the first step in getting users to install your PWA. To implement your own install experience, your app still needs to pass the install criteria: when the browser detects that your app is installable, it fires the beforeinstallprompt event.
If your website meets the Progressive Web App installability criteria, Chrome will show an install button in the omnibox indicating, that your Progressive Web App can be installed. If the user clicks the install button, an install dialog box will appear, making it easy for a user to install your PWA.
For sites that pass the PWA install criteria, the browser triggers an event to prompt the user to install it. The good news is that you can use this event to customize your prompt and invite users to install your app. Users may not be familiar with the PWA install process.
Chrome and Edge on iOS and iPadOS do not support PWA installation, so the beforeinstallprompt event can't fire. In this case, the only option is to open the PWA using Safari, where it is installable from the share, add to the home screen menu.
Supposing you want to prevent the default so as to show a customized install banner, read here.
However, this script would totally prevent the install banner!
window.addEventListener('beforeinstallprompt', (e) => {
// Prevent Chrome 67 and earlier from automatically showing the prompt
e.preventDefault();
});
For making your PWA installable only on mobile and not on desktop you can choose one of the following methods:
Redirect to a subdomain or another domain that does not have a manifest file
If you are using Server-Side-Rendering, remove the manifest link
tag before sending to the client
<!-- do not include this if the client userAgent is a desktop device (wide screen) -->
<link rel="manifest" href="./manifest.json"/>
Remove manifest on the client once the page is loaded on desktop
window.addEventListener("load", function() {
if (navigator.userAgent.indexOf('Mobile') === -1) {
document.querySelector('link[rel="manifest"]').remove();
}
});
That way it will make your PWA not installable and thus not showing the Add to Home screen in the omnibox.
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