Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent PWA from being installed

Is there any way to configure my manifest.json to disable the browser popup asking to "install" the site? I'm using the following JavaScript code to prevent it:

window.addEventListener('beforeinstallprompt', function(e) {
    e.preventDefault();
    return false;
});

But I need to prevent it also on the AMP version, and I can't run JavaScript code there.

like image 649
Spike886 Avatar asked Jan 18 '17 04:01

Spike886


People also ask

How do I disable PWA?

From your app drawer or home screen, open Settings . See all apps. Find the PWA you want to remove and tap the icon. Tap Uninstall.

Does PWA need to be installed?

There is no need to search, download and update a PWA as with a native App; rather, users can download the App quickly and directly to their device.

How do I know if PWA is installed?

Check if your PWA is installed # Finally, call navigator. getInstalledRelatedApps() from within the scope of your PWA to check if it is installed.


2 Answers

Currently, there doesn't appear to be an explicit setting to disable app install.

One workaround is to edit manifest.json so that it doesn't meet the required criteria for app install banner, such as removing short_name or icons declarations.

like image 147
tony19 Avatar answered Oct 19 '22 07:10

tony19


You can do:

window.addEventListener('beforeinstallprompt', (event) => {
  event.preventDefault()
})

Another workaround would be to set the display: 'browser' option in the site.webmanifest.

like image 2
Maurici Abad Avatar answered Oct 19 '22 07:10

Maurici Abad