window.addEventListener('beforeinstallprompt', (e) => { e.preventDefault(); // Store the event for later use window.deferredPrompt = e; // Show install button if available const installButton = document.querySelector('.pwa-install-button'); if (installButton) { installButton.style.display = 'block'; installButton.addEventListener('click', () => { // Show installation prompt const promptEvent = window.deferredPrompt; if (promptEvent) { promptEvent.prompt(); promptEvent.userChoice.then((choiceResult) => { if (choiceResult.outcome === 'accepted') { console.log('User accepted the install prompt'); } window.deferredPrompt = null; }); } }); } }); });