6

I'm showing a custom PWA install popup to the user using beforeinstallprompt event before showing the native install popup. For some of our users, who already installed the PWA to their desktop, are getting the custom popup again. The only way for that happening is that the beforeinstallprompt event is firing again. Is that possible?

Will browser fire beforeinstallprompt event even when PWA is installed to the user system?

Issues are reported for Google Chrome.

Asim K T
  • 16,864
  • 10
  • 77
  • 99
  • It shouldn't. Desktop or mobile? Perhaps the user(s) cleared their browser's cache at some point then were prompted again when visiting your site? – Mathias Jul 11 '19 at 14:42
  • @Mathias Desktop. I'm also thinking the same, but the user reported as the app is already installed and didn't clear cache. Is there a definition for when to throw this event by a browser? – Asim K T Jul 12 '19 at 05:45
  • In the Chrome desktop, it currently fires in seconds if all the criteria are correct. If possible, next time this happens have the user go here ( chrome://apps/) in their browser to see if they see your Icon. Most likely they will not which means that it was somehow un-installed. – Mathias Jul 12 '19 at 10:27
  • 2
    @AsimKT Did you find out any solution of this? – Nishant Dixit Oct 27 '20 at 16:43

1 Answers1

1

Actually, I came across this issue today. Hope I'm not late to the party. Anyway, what I did was that I listened to the event fired when a user has successfully accepted the installation of the "app" then I hid the custom install button. This is because chrome automatically launches the installed "app".

Actually, before showing the user the button to install your app, check if the app was first launched via the app itself or directly from the browser using:

 if(windows.matchMedia.("(display-mode:standalone)").matches)
{
    //do not show the button
}.

Hope this helps.

Hackhim
  • 11
  • 1
  • 2
    Hi, I guess your answer deals with not showing the popup if the app is standalone. In your case, I would still be getting an Add to Homescreen prompt on my web browser when I visit the page. Here, we want to know why are we getting the prompt on the web browser when we have the webpage installed already. – Rahul Sharma Feb 19 '20 at 10:37