DIGITAL COMPANION
--°C
Pretoria
window.addEventListener('beforeinstallprompt', (e) => { e.preventDefault(); deferredPrompt = e; if (!isStandalone() && !hasDismissedInstall()) { showInstallButton(); } }); window.addEventListener('appinstalled', () => { deferredPrompt = null; hideInstallButton(); setDismissedInstall(true); console.log('PWA installed'); }); document.getElementById('installAppBtn').addEventListener('click', async () => { if (isStandalone()) { hideInstallButton(); return; } if (isIos()) { alert('To install Guest App on iPhone: tap Share, then tap "Add to Home Screen".'); return; } if (deferredPrompt) { deferredPrompt.prompt(); const choice = await deferredPrompt.userChoice; deferredPrompt = null; if (choice && choice.outcome !== 'accepted') { setDismissedInstall(true); hideInstallButton(); } return; } alert('To install Guest App: open your browser menu and tap "Install app" or "Add to Home screen".'); }); window.onload = function() { getWeather(); if (isStandalone()) { hideInstallButton(); return; } if (!hasDismissedInstall()) { showInstallButton(); } };