Vishal Vijay
Vishal Vijay

Reputation: 2528

beforeinstallprompt event is triggered for a origin or for a service worker scope

Assume we have a website www.example.com and we are running 2 different service worker under different scopes.

Now we want to allow users to install these PWA as an app in their launcher. And browser trigger beforeinstallprompt event to handle this, based on a few criteria. Also, if the user declines the installation, it might not trigger this event for the next 3 months.

So my questions are:

  1. Do we get beforeinstallprompt event triggered separately for pwa1 and pwa2 or is it considered for an origin?
  2. If the user declines the prompt in pwa1, does this have any impact in pwa2?

Upvotes: 0

Views: 635

Answers (1)

PeteLe
PeteLe

Reputation: 1945

  1. The beforeinstallprompt event will be triggered separately. A PWA is based on the manifest and the scope defined in it.
  2. Chrome treats them as separate apps, if the user accepts or declines one, it will not affect the other.

Also, if the user declines the installation, it might not trigger this event for the next 3 months.

This is only the case for the mini-infobar shown on Chrome for Android. The beforeinstallprompt event will always be triggered if the site meets the install criteria, allowing you to add your own install promotion.

Upvotes: 1

Related Questions