let deferredPrompt;
/* -----------------------------
ANDROID / CHROME INSTALL FLOW
------------------------------*/
window.addEventListener("beforeinstallprompt", (e) => {
e.preventDefault();
deferredPrompt = e;
// Prevent duplicate banner
if (document.getElementById("install-banner")) return;
showInstallBanner({
message: '📱 Install Quality App?',
buttonText: 'Install',
onClick: async () => {
deferredPrompt.prompt();
const { outcome } = await deferredPrompt.userChoice;
console.log("User install choice:", outcome);
deferredPrompt = null;
}
});
});
// /* -----------------------------
// IOS SAFARI MANUAL INSTALL
// ------------------------------*/
// function isIosSafari() {
// return (
// /iP(ad|hone|od)/.test(navigator.userAgent) &&
// /Safari/.test(navigator.userAgent) &&
// !/CriOS|FxiOS|OPiOS/.test(navigator.userAgent)
// );
// }
// function isInStandaloneMode() {
// return window.navigator.standalone == true;
// }
// document.addEventListener("DOMContentLoaded", () => {
// if (
// isIosSafari() &&
// !isInStandaloneMode() &&
// !localStorage.getItem("iosInstallShown")
// ) {
// showInstallBanner({
// message: '📱 Install Quality App
Tap Share ⬆️ → Add to Home Screen',
// buttonText: 'Got it',
// onClick: () => {
// localStorage.setItem("iosInstallShown", "1");
// }
// });
// }
// });
/* -----------------------------
COMMON INSTALL BANNER UI
------------------------------*/
function showInstallBanner({ message, buttonText, onClick }) {
if (document.getElementById("install-banner")) return;
const banner = document.createElement("div");
banner.id = "install-banner";
banner.innerHTML = `