You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are currently two ways to find out whether the user installed your app or not:
The appinstalled event. (Only gives you a positive answer, doesn't tell you if they cancelled the install prompt.)
The beforeinstallprompt event: call prompt(). The result of prompt tells you whether the user accepted.
Chrome's implementation has an additional userChoice attribute (on the BeforeInstallPromptEvent) that lets you passively detect prompt acceptance/denial without calling prompt().
There's one problem with using prompt() instead of a passive userChoice: it may produce slightly different prompting behaviour.
As the spec currently stands, calling prompt() in the beforeinstallprompt event handler is a no-op; it doesn't change the behaviour at all (which defaults to prompting), and therefore, prompt() in the event handler is equivalent to userChoice. However, #576 calls for a change to allow user agents to not prompt by default, but show a prompt if prompt() is called. This means developers using prompt() as a substitute for userChoice would suddenly get non-default behaviour. There would be no way for a site to passively detect prompt acceptance/denial without inadvertently forcing the prompt to be shown.
Some possible approaches here (presented without opinion):
"This use case is not important enough; if you care enough about collecting data, then you can decide for yourself when the prompt should be shown and not rely on the default behaviour. Or use appinstalled to collect data."
"We do want a way to let developers passively collect this data. Let's add Chrome's userChoice."
"We do want a way to let developers passively collect this data. But userChoice (being an attribute promise) is weird; let's design something else."
Thoughts?
The text was updated successfully, but these errors were encountered:
There are currently two ways to find out whether the user installed your app or not:
appinstalled
event. (Only gives you a positive answer, doesn't tell you if they cancelled the install prompt.)beforeinstallprompt
event: callprompt()
. The result ofprompt
tells you whether the user accepted.Chrome's implementation has an additional
userChoice
attribute (on theBeforeInstallPromptEvent
) that lets you passively detect prompt acceptance/denial without callingprompt()
.There's one problem with using
prompt()
instead of a passiveuserChoice
: it may produce slightly different prompting behaviour.As the spec currently stands, calling
prompt()
in thebeforeinstallprompt
event handler is a no-op; it doesn't change the behaviour at all (which defaults to prompting), and therefore,prompt()
in the event handler is equivalent touserChoice
. However, #576 calls for a change to allow user agents to not prompt by default, but show a prompt ifprompt()
is called. This means developers usingprompt()
as a substitute foruserChoice
would suddenly get non-default behaviour. There would be no way for a site to passively detect prompt acceptance/denial without inadvertently forcing the prompt to be shown.Some possible approaches here (presented without opinion):
prompt()
is just as good asuserChoice
".appinstalled
to collect data."userChoice
."userChoice
(being an attribute promise) is weird; let's design something else."Thoughts?
The text was updated successfully, but these errors were encountered: