installEvent:any=null;
@HostListener('window: beforeinstallprompt', ['$event'])
onBeforeInstallPrompt(event:Event){
console.log(event);
event.preventDefault();
this.installEvent = event;
}
installByUser(){
if(this.installEvent){
this.installEvent.prompt();
this.installEvent.userChoice
.then((rta: any)=>{
if (rta.outcome === 'accepted') {
console.log('User accepted the A2HS prompt');
} else {
console.log('User dismissed the A2HS prompt');
}
});
}
}
Logre implementarlo casi igual, solo agregando tipado por las últimas versiones de ts. Saludos 😃
¿Quieres ver más aportes, preguntas y respuestas de la comunidad?