"use client"; import { useEffect, useState } from "react"; type BeforeInstallPromptEvent = Event & { prompt: () => Promise; userChoice: Promise<{ outcome: "accepted" | "dismissed"; platform: string }>; }; export default function PwaInstallPrompt() { const [deferredPrompt, setDeferredPrompt] = useState(null); const [isInstalled, setIsInstalled] = useState(false); useEffect(() => { const onBeforeInstallPrompt = (event: Event) => { event.preventDefault(); setDeferredPrompt(event as BeforeInstallPromptEvent); }; const onAppInstalled = () => { setIsInstalled(true); setDeferredPrompt(null); }; const isStandalone = window.matchMedia("(display-mode: standalone)").matches; if (isStandalone) { setIsInstalled(true); } window.addEventListener("beforeinstallprompt", onBeforeInstallPrompt); window.addEventListener("appinstalled", onAppInstalled); return () => { window.removeEventListener("beforeinstallprompt", onBeforeInstallPrompt); window.removeEventListener("appinstalled", onAppInstalled); }; }, []); if (!deferredPrompt || isInstalled) return null; return (

Instala OpenCCB para acceso rapido y soporte offline.

); }