Ejemplo 1: instalación de pwa
buttonInstall.addEventListener('click', (e) => { // Hide the app provided install promotion hideMyInstallPromotion(); // Show the install prompt deferredPrompt.prompt(); // Wait for the user to respond to the prompt deferredPrompt.userChoice.then((choiceResult) => { if (choiceResult.outcome === 'accepted') { console.log('User accepted the install prompt'); } else { console.log('User dismissed the install prompt'); } });});
Ejemplo 2: A2HS
Add to Home screen or (A2HS)
Ejemplo 3: instalación de pwa
let deferredPrompt;window.addEventListener('beforeinstallprompt', (e) => { // Prevent the mini-infobar from appearing on mobile e.preventDefault(); // Stash the event so it can be triggered later. deferredPrompt = e; // Update UI notify the user they can install the PWA showInstallPromotion();});
¡Haz clic para puntuar esta entrada!
(Votos: 1 Promedio: 1)