I have the following code that only fires if serviceworker is not yet installed, if I reload the page, it no longer fires, I did not add the code yet to install the PWA (deferredprompt does nothing). I'm using Chrome. I am not declining the prompt, I am not even displaying the prompt at the moment.

let deferredPrompt = null;
    window.addEventListener('beforeinstallprompt', (e) => {
        // Prevent Chrome 67 and earlier from automatically showing the prompt
        e.preventDefault();

        consolelog('=== before install prompt fired ===', 3)
        // Stash the event so it can be triggered later.
        deferredPrompt = e as any;



    });

1 Answers

1
bluepoisondartfrog On Best Solutions

The event fires immediately on load (if you have a serviceworker installed), and I was wiring up the event too late, so I missed it.