Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PWA: How to retrigger beforeinstallprompt?

Our site uses PWA so that the visitor can choose to Add to Home Screen (A2HS). However, from Google Analytics data, the Dismiss rate is too high compared to Acceptance rate.

We plan to make the UX more intuitive and clearer to improve the acceptance rate. However, we also want to revive those visitors already dismissed the A2HS dialog.

How to do so? To the extend of my knowledge, we only can add beforeinstallprompt listener but there is no openinstallprompt method.

like image 655
Pahlevi Fikri Auliya Avatar asked May 18 '18 03:05

Pahlevi Fikri Auliya


People also ask

How do I prompt user to install PWA?

Open the menu next to the URL bar. Depending on whether you're using Chrome or Android you'll see a menu option "Install" or "Install App". This is the "Add to Home screen" option displayed for any site that has the necessary features in place.

Where do I put Beforeinstall prompt?

The BeforeInstallPromptEvent is the interface of the beforeinstallprompt event fired at the Window object before a user is prompted to "install" a website to a home screen on mobile.


1 Answers

In Dev mode,

Try this in devtools(tried in chrome) console to trigger the event:

event = new Event('beforeinstallprompt')
window.dispatchEvent(event)

Caution: We won't be able to open the in-browser modal by calling prompt on the event.

like image 136
Souvik Saha Avatar answered Oct 01 '22 01:10

Souvik Saha