export default defineNuxtPlugin(() => { if (process.client) { let deferredPrompt: any = null // Listen for PWA install prompt window.addEventListener('beforeinstallprompt', (e) => { console.log('[PWA] Install prompt available') e.preventDefault() deferredPrompt = e // Show custom install button or notification showInstallNotification() }) // Listen for successful installation window.addEventListener('appinstalled', () => { console.log('[PWA] App successfully installed') deferredPrompt = null // Hide install notification hideInstallNotification() // Show success message showInstallSuccess() }) // Function to trigger install const installPWA = async () => { if (!deferredPrompt) { console.log('[PWA] No install prompt available') return } try { deferredPrompt.prompt() const { outcome } = await deferredPrompt.userChoice if (outcome === 'accepted') { console.log('[PWA] User accepted install') } else { console.log('[PWA] User dismissed install') } deferredPrompt = null } catch (error) { console.error('[PWA] Install error:', error) } } // Show install notification const showInstallNotification = () => { // Create install notification if it doesn't exist if (!document.getElementById('pwa-install-notification')) { const notification = document.createElement('div') notification.id = 'pwa-install-notification' notification.innerHTML = `