Skip to content

Provide a way to find out the result of the install prompt without prompt() #578

@mgiuca

Description

@mgiuca

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):

  • "We aren't going to action Install prompts: Allow manual prompting but not automatic prompting #576, and therefore prompt() is just as good as userChoice".
  • "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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions