How to detect if PWA is already installed on IOS

Viewed 3290

I have PWA angular application and I want to show user popup that he/she can add application on homescreen.

I don't want this notification to be shown in PWA but only IOS Safari, so I use this check:

const isInStandaloneMode = () => ('standalone' in window.navigator) && (window.navigator.standalone);

I also don't want to show this popup on IOS Safari when user already installed PWA, is there any chance to check whether or not PWA is already installed?

1 Answers

Yes, that code will return true if the user launched your PWA from the home screen on iOS.

You could also simplify your code a bit to:

const iOSCanInstall = 'standalone' in window.navigator;
const iOSIsInstalled = window.navigator.standalone === true;

That way, you know if they're an iOS user who can potentially install your PWA or not, and if they've opened your PWA from the home screen.

If the user opens your PWA in the browser, unfortunately there is no way to check if it's already been installed. In Chrome/Edge, you could use getInstalledRelatedApps(), but sadly that doesn't help with your question.

Related