demo · v140
Install Banner Logic
A real bizdev policy: don't show the "install our app" banner if any related app is already installed (native or PWA), and don't show it on the marketing page if a paid subscription is active. Toggle inputs, see the decision tree update live, the banner appears or disappears.
simulate state:
Android/Windows installed
PWA installed
Subscription active
On marketing page
Dismissed banner last 7 days
Some page content goes here.
const installed = await navigator.getInstalledRelatedApps();
const hasNative = installed.some(a => a.platform === "play"
|| a.platform === "windows");
if (hasNative) return suppress("native app already installed");
if (await isPwaInstalled()) return suppress("PWA already installed");
if (await hasSubscription()) return suppress("user is paying");
if (dismissedRecently()) return suppress("recently dismissed");
showInstallBanner();
see also
- Get Installed Related Apps API — feature index
- web.dev: get-installed-related-apps