getInstalledRelatedApps(): detecting an installed native or PWA counterpart
Published
In one line: navigator.getInstalledRelatedApps() resolves with the related,
platform-specific apps or PWAs — declared in the calling web app’s manifest — that are
already installed on the user’s device.
What it checks for
Section titled “What it checks for”getInstalledRelatedApps() can be used to check for the installation of Universal
Windows Platform (UWP) apps, Android apps, and PWAs that are related to the web app
calling this method. To associate the invoking web app with a platform-specific app or
PWA, two things must be done:
- The invoking web app’s manifest must list the related Android app, UWP app, or PWA in
its own
related_applicationsmember. - The platform-specific app or PWA must have its relationship with the invoking app
defined, verified in a platform-specific way:
- An Android app defines the relationship via the Digital Asset Links system.
- A Windows UWP app defines it via URI Handlers.
- A PWA defines it either through a self-referencing entry in its own
related_applicationsmember (specifyingplatformandid), or — for an app outside the PWA’s own scope checking whether it is installed on Android — via anassetlinks.jsonfile in that PWA’s/.well-known/directory.
Return value
Section titled “Return value”getInstalledRelatedApps() takes no parameters and returns a promise that fulfills with
an array of objects, one per installed related app, each of which can include:
id(optional) — a platform-specific string identifying the app.platform— the ecosystem or OS the app belongs to:"chrome_web_store","play","chromeos_play","webapp","windows","f-droid", or"amazon".url(optional) — the URL associated with the app, typically where it can be installed or read about.version(optional) — the related app’s version.
const relatedApps = await navigator.getInstalledRelatedApps();const psApp = relatedApps.find((app) => app.id === 'com.example.myapp');if (psApp) { // A related platform-specific app is already installed.}Calling the method outside a top-level browsing context throws an InvalidStateError
DOMException.
Practical checklist
Section titled “Practical checklist”- List the related Android app, UWP app, or PWA in the calling web app’s own
manifest
related_applicationsmember. - Set up the platform-specific verification the related app needs: Digital Asset
Links for Android, URI Handlers for UWP, or a self-referencing
related_applicationsentry (or/.well-known/assetlinks.json) for a related PWA. - Call
getInstalledRelatedApps()only from a top-level browsing context to avoid anInvalidStateError. - Use the resolved
platform/idvalues to decide whether to suppress your own install prompt or feature (for example, skip prompting to install the PWA when a native counterpart is already present).
Cross-references
Section titled “Cross-references”- The install prompt — combining this check
with
beforeinstallpromptto suppress prompting when a related app is installed