<h4>PWA Install — Code Fixes</h4><h5>Why Install Prompt Doesn't Show:</h5><p>Primary: The site is on HTTP (<code>http://152.youportal.lcl</code>). PWA install requires <strong>HTTPS</strong> (or localhost). On production HTTPS domains, the install prompt will now work after these code fixes.</p><h5>Code Issues Fixed:</h5><ul><li><strong>Service Worker registration too late:</strong> The SW was only registered inside the <code>appinstalled</code> event (after install). But the browser needs the SW registered BEFORE it can show the install prompt. Moved <code>navigator.serviceWorker.register('/sw.js')</code> to run on page load, before everything else.</li><li><strong>Install button hidden when it should show:</strong> The <code>beforeinstallprompt</code> handler checked <code>$_SESSION['application'] == 1</code> to decide whether to show the <code>.a2hs-button</code>. If the session variable was empty (which it often is), the button was hidden. Fixed: the <code>beforeinstallprompt</code> event itself means the app IS installable — always show the button when this event fires.</li><li><strong>Duplicate click handlers:</strong> Used <code>.off('click').on('click')</code> to prevent stacking event handlers.</li><li><strong>Empty manifest scope:</strong> <code>scope:''</code> changed to <code>scope:'/'</code> in manifest.json.</li></ul><h5>Manifest Validation:</h5><p>All PWA requirements met: name, short_name, start_url, display:standalone, 7 icons including 192x192 and 512x512, theme_color, background_color.</p><h5>What's Needed for Install to Work:</h5><ol><li><strong>HTTPS</strong> — configure SSL/TLS on the production domain</li><li>Code fixes above (done)</li><li>Valid manifest (confirmed)</li><li>Registered service worker (fixed — now registers on page load)</li></ol><p><strong>File:</strong> platform/main.template.php, website/assets/1/website-branding/favicon/manifest.json</p>