- From: Matt Giuca <notifications@github.com>
- Date: Sun, 16 Oct 2016 16:18:32 -0700
- To: w3c/manifest <manifest@noreply.github.com>
- Message-ID: <w3c/manifest/issues/417/254082806@github.com>
There's a lot to unpack there. To specifically enumerate what you're proposing (from my reading of the example): 1. `prompt()` resolves only when the user makes a choice (whereas currently it resolves immediately). 2. `prompt()` returns the user's choice directly, so there is no need to request `userChoice` on the event (whereas currently it returns `void`). I much prefer this. I only realised while reviewing your patch that propmpt resolves immediately and I thought that was weird. Note that we still need `userChoice` on the event, because it is used to tell us about the user's choice when the banner is automatically shown. In your above example, you aren't recording analytics in the early return case. What you need there is: ```js window.onbeforeinstallprompt = async function ( e ) { var choice; if (!userIsDoingThings) { choice = await e.userChoice; // automatically show it. } else { e.preventDefault(); await Promise.all(thingsTheUserIsDoingThatBlockInstall); const promptResult = await ev.prompt(); choice = promptResult.userChoice; } switch (choice) { case "dismissed": // The user didn't want the app 😢 analytics({ userHatesUs: true }); break; case "accepted": // Awesome! it's installing analytics({ userHatesUs: false }); break; default: console.error(`Unknown choice? ${choice}`); } } ``` You could use `appinstalled` to figure out when the user accepts the automatic prompt, but there is no signal to tell you when the user has cancelled it, other than the rejection of `BeforeInstallPromptEvent.userChoice`. Whether we want to make breaking changes is something we need data for and I don't personally feel comfortable making that decision (would want to speak with Alex again). -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/manifest/issues/417#issuecomment-254082806
Received on Sunday, 16 October 2016 23:18:59 UTC