[w3c/manifest] beforeinstallprompt not called (#688)

Hello I'm trying to install a custom PWA "Add to Homescreen".
The ServiceWorkerRegistration is successful.

But the function beforeinstallpromp is not calling after register.

```
<script type="text/javascript">
  
  function request_debug(paramdata){
    
    document.getElementById('output').innerHTML += '<BR>'+ paramdata;

  }
  
  window.addEventListener('load', function() {
                          
      document.getElementById('output').style.display = "block"; 
  
      if('serviceWorker' in navigator) {

      navigator.serviceWorker.register('sw.js').then(function(registration) {
        console.log('Service worker  registrado com sucesso:', registration);
        request_debug(registration);

      }).catch(function(error) {
        console.log('Falha ao Registrar o Service Worker:', error);
        request_debug(error);

      });

          var isTooSoon = true;
          window.addEventListener('beforeinstallprompt', function(e) {

              //e.preventDefault();
              //e.prompt();
              //promptEvent = e;
              request_debug(' window.addEventListener beforeinstallprompt fired!')

              if (isTooSoon) {
                //e.preventDefault(); // Prevents prompt display
                // Prompt later instead:
                setTimeout(function() {
                  isTooSoon = false;
                  e.prompt(); // Throws if called more than once or default not prevented
                }, 4000);
              }
 
          });

    }else{

      console.log('serviceWorker not in navigator');
      request_debug('serviceWorker not in navigator');

    }

    
  });
  
</script>
```

Also my service worker in root directory...

my manifest:

```
{
  "background_color": "purple",
  "description": "lojaportaldotricot TESTE",
  "display": "standalone",
  "icons": [
    {
      "src": "/componentes/serviceWorker/fox-icon.png",
      "sizes": "192x192",
      "type": "image/png"
    }
  ],
  "name": "lojaportaldotricot",
  "short_name": "lojaportaldotricot",
  "start_url": "/dashboard"
}
```
It's only workes when I set "Enable" chrome://flags/#bypass-app-banner-engagement-checks


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/manifest/issues/688

Received on Friday, 8 June 2018 14:15:22 UTC