buttonInstall.addEventListener('click', async () => { // Hide the app provided install promotion hideInstallPromotion(); // Show the install prompt deferredPrompt.prompt(); // Wait for the user to respond to the prompt const { outcome } = await deferredPrompt.userChoice; // Optionally, send analytics event with outcome of user choice console.log(`User response to the install prompt: ${outcome}`); // We've used the prompt, and can't use it again, throw it away deferredPrompt = null; });