- Notifications
You must be signed in to change notification settings - Fork 174
Description
There are currently two ways to find out whether the user installed your app or not:
- The
appinstalledevent. (Only gives you a positive answer, doesn't tell you if they cancelled the install prompt.) - The
beforeinstallpromptevent: callprompt(). The result ofprompttells 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):
- "We aren't going to action Install prompts: Allow manual prompting but not automatic prompting #576, and therefore
prompt()is just as good asuserChoice". - "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
appinstalledto 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?