My side project Clipzy (a free video downloader and AI Shorts maker) is mostly used on phones. People download a TikTok, then come back the next day to download another. An app icon on the home screen makes a lot of sense for that.
Adding @angular/service-worker and a manifest gets you a PWA. Making install and updates work well on both Android and iPhone took a lot more. Here are the three services I ended up with, all using signals and safe to run with SSR.
1. Android/desktop: capture beforeinstallprompt
Chrome and Edge fire beforeinstallprompt when your app qualifies for install. If you save that event, you can trigger the install dialog later from your own button.
TypeScript doesn't ship a type for it, so declare one:
interface BeforeInstallPromptEvent extends Event { readonly platforms: string[]; readonly userChoice: Promise<{ outcome: 'accepted' | 'dismissed'; platform: string }>; prompt(): Promise<void>; } The service:
@Injectable({ providedIn: 'root' }) export class InstallPromptService { private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID)); private deferredPrompt: BeforeInstallPromptEvent | null = null; readonly canInstall = signal(false); readonly isInstalled = signal(false); constructor() { if (!this.isBrowser) return; // SSR: no window this.isInstalled.set(this.detectStandalone()); window.addEventListener('beforeinstallprompt', (event) => { this.deferredPrompt = event as BeforeInstallPromptEvent; this.canInstall.set(true); }); window.addEventListener('appinstalled', () => { this.deferredPrompt = null; this.canInstall.set(false); this.isInstalled.set(true); }); } async promptInstall(): Promise<'accepted' | 'dismissed' | 'unavailable'> { if (!this.deferredPrompt) return 'unavailable'; await this.deferredPrompt.prompt(); const { outcome } = await this.deferredPrompt.userChoice; this.deferredPrompt = null; // an event can only be used once this.canInstall.set(false); return outcome; } private detectStandalone(): boolean { const standaloneDisplay = window.matchMedia?.('(display-mode: standalone)').matches ?? false; const iosStandalone = (navigator as Navigator & { standalone?: boolean }).standalone === true; return standaloneDisplay || iosStandalone; } } The navbar shows an "Install Clipzy" button when canInstall() is true. Instead of jumping straight to the browser dialog, it first opens a small popup that explains why installing is worth it:

Clicking "Install Clipzy" in the navbar opens a short onboarding popup. Its "Install Clipzy" button calls promptInstall(), which shows the browser's install dialog.
About preventDefault(): many tutorials tell you to call event.preventDefault() to hide Chrome's own install banner. If you do that and never call prompt(), Chrome logs Banner not shown: beforeinstallpromptevent.preventDefault() called, and the user gets no install banner at all. I stopped calling it. Chrome can show its own banner, and my button still works because I still save the event.
2. iPhone: there is no install event
Safari on iOS never fires beforeinstallprompt. The only way to install is Share → Add to Home Screen, and most people don't know that exists. So on iOS, the same "Install" button opens a small modal with step-by-step instructions instead.
The difficult part is figuring out when you're actually in iOS Safari:
private detectIosSafari(): boolean { const ua = navigator.userAgent; const isIosDevice = /iphone|ipad|ipod/i.test(ua) || // iPadOS 13+ claims to be a Mac. Real Macs have no touch points. (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1); // Chrome, Firefox and Edge on iOS all use WebKit and include "Safari" in the UA, // but they can't add to the home screen the same way, so exclude them. const isOtherIosBrowser = /crios|fxios|edgios|opios|duckduckgo/i.test(ua); const isSafari = /safari/i.test(ua) && !isOtherIosBrowser; return isIosDevice && isSafari; } Two gotchas in there:
- iPads report themselves as Macs. Since iPadOS 13, Safari on iPad sends a desktop Mac user agent. The
maxTouchPoints > 1check tells them apart. - Every iOS browser says "Safari". Chrome for iOS has
CriOSandSafariin its user agent, so you have to exclude the others explicitly.
The iOS service also:
- Only shows the button when
isIosSafari && !isInstalled() && !dismissedForever() - Saves a "don't show again" choice in
localStorage, so you don't nag people who said no - Reuses
isInstalled()from the Android service, so standalone detection lives in one place
3. Installed PWAs don't reload, so tell users about updates
This one surprised me. In a browser tab, people refresh all the time. An installed PWA on a phone gets resumed from the background for days and never reloads. Angular's service worker only checks for new versions on navigation or reload, so installed users stayed on old builds.
(If your server caches ngsw.json, updates never arrive. I wrote about that in my previous post.)
My AppUpdateService checks in three situations:
// 1) Once the app is stable, then every 30 minutes const appIsStable$ = this.appRef.isStable.pipe(first(stable => stable)); concat(appIsStable$, interval(30 * 60 * 1000)) .pipe(takeUntilDestroyed()) .subscribe(() => this.swUpdate.checkForUpdate()); // 2) Every time the app comes back to the foreground (the important one on phones) document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible') { this.swUpdate.checkForUpdate().catch(() => undefined); } }); // 3) If the cached version is broken (its files were deleted from the server), just reload this.swUpdate.unrecoverable .pipe(takeUntilDestroyed()) .subscribe(() => window.location.reload()); Waiting for isStable first matters. Angular's docs warn that polling before the app is stable can stop the service worker from registering at all. (I also register with registrationStrategy: 'registerWhenStable:30000'.)
Don't nag on every launch
When a VERSION_READY event arrives, I show a modal with the release notes ("Update now / Later"). If the user picks Later, it turns into a small banner on the home page. If they dismiss the banner, it disappears until the next version.
The trick is to save the choice per version hash:
type StoredChoice = 'later' | 'dismissed'; interface StoredState { hash: string; choice: StoredChoice; } private presentForCurrentState(): void { const hash = this.pendingEvent!.latestVersion.hash; const stored = this.readState(); // from localStorage if (stored?.hash !== hash) { // A version we haven't asked about yet: start with the modal this.modalVisible.set(true); this.bannerVisible.set(false); return; } this.modalVisible.set(false); this.bannerVisible.set(stored.choice === 'later'); } "Update now" calls swUpdate.activateUpdate() and then reloads, so every file comes from the new version:
activateUpdate(path?: string): void { const go = () => (path ? (window.location.href = path) : window.location.reload()); if (!this.swUpdate.isEnabled) { go(); return; } this.swUpdate.activateUpdate().catch(() => undefined).finally(go); } Bonus: an offline banner in 10 lines
A downloader is useless offline, so show a clear message instead of failing requests:
@Injectable({ providedIn: 'root' }) export class OnlineStatusService { readonly isOnline = signal(true); constructor() { if (!isPlatformBrowser(inject(PLATFORM_ID))) return; this.isOnline.set(navigator.onLine); window.addEventListener('online', () => this.isOnline.set(true)); window.addEventListener('offline', () => this.isOnline.set(false)); } } The banner component keeps the check inside its own template, so app.component.html just includes <app-offline-banner />:
@if (!onlineStatusSvc.isOnline()) { <div class="offline-banner" role="status" aria-live="polite"> You're offline. Some features, like downloading videos, need an internet connection. </div> } role="status" with aria-live="polite" makes screen readers announce it when the connection drops.
Checklist
- [ ] Save
beforeinstallpromptfor your own button, and don'tpreventDefault()unless you always callprompt() - [ ] Detect
display-mode: standaloneandnavigator.standalone(iOS) - [ ] Show "Add to Home Screen" steps on iOS Safari only, and remember when users dismiss them
- [ ] Detect iPadOS by checking
MacInteltogether with touch points - [ ] Check for updates on
visibilitychange, not just on reload - [ ] Wait for
ApplicationRef.isStablebefore polling - [ ] Handle
SwUpdate.unrecoverable - [ ] Remember the user's update choice per version hash
- [ ] Wrap every
window/navigatoraccess inisPlatformBrowserif you use SSR
You can try the install flow on your phone at clipzy.video. On iPhone, open it in Safari and tap "Install Clipzy."
How do you handle PWA updates? Do you force a reload, or ask the user? Tell me in the comments.