8

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.

Alex Angas
  • 59,219
  • 41
  • 137
  • 210
Spike886
  • 609
  • 8
  • 23

3 Answers3

8

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.

tony19
  • 125,647
  • 18
  • 229
  • 307
  • It's a very clever idea, but isn't any other alternative? – Spike886 Jan 18 '17 at 05:45
  • There doesn't appear to be an explicit setting to disable app install, so I don't think there's another option. It doesn't sound like you're even using the `short_name` or `icon` if you don't want the app installation. – tony19 Jan 18 '17 at 05:49
4

You can do:

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

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

Maurici Abad
  • 1,012
  • 9
  • 20
0

Instead of editing my manifest.json file, I tried removing the link to it from within my index.html. I deleted the line:

<link rel="manifest" href="manifest.json">

This seemed to work fine in my case.

CKP78
  • 630
  • 8
  • 19