Not getting PWA install prompt

I have a vanilla ionic5 angular9 application.

I then run ng add @angular/pwa.

I deploy to firebase and run lighthouse. I get perfect PWA score.

BUT, I am not getting install prompt.
The app has NOT been previously installed.
I’ve tried 3 different browers on 2 different PCs.

I’ve been at this for hours. Very frustrating.
Thanks for any help.

1 Like

Chrome is very iffy about their install prompt. Sometimes it shows it, sometimes it doesn’t. Here’s a little snippet I’ve been using for a while.

import { Component, OnInit } from '@angular/core';
import { fromEvent } from 'rxjs';

@Component({
  selector: 'app-landing',
  templateUrl: './landing.page.html',
  styleUrls: ['./landing.page.scss'],
})
export class LandingPage implements OnInit {
  ev: any;
  ngOnInit() {
    fromEvent(window, 'beforeinstallprompt').subscribe((res: any) => {
      console.log(res);
      this.ev = res;
    });
  }
  push() {
    if (this.ev) {
      this.ev.preventDefault();
      this.ev.prompt();
      this.ev.userChoice.then((choiceResult: { outcome: string }) => {
        if (choiceResult.outcome === 'accepted') {
          console.log('User accepted the A2HS prompt');
        } else {
          console.log('User dismissed the A2HS prompt');
        }
      });
    }
  }
}

Then in the template

<ion-content class="ion-padding ion-text-center">
  <h3>Welcome to Star Track
    <ion-icon name="musical-notes" color="primary"></ion-icon>
  </h3>
  <p>Star Track is a simple way to interact with Apple Music.</p>
  <ion-button (click)="push()" routerLink="/browse" [replaceUrl]="true">Get Started</ion-button>
</ion-content>