demo · v140
Cross-Platform Router
A click-handler that asks navigator.getInstalledRelatedApps() which of your native apps the user has, then routes accordingly. Toggle the simulated install state of an Android app, a Windows MSIX, and a PWA, and watch the "open in" behaviour change.
API not detected
Your browser doesn't expose
navigator.getInstalledRelatedApps. The probes below use the simulated values you toggle.
simulate which apps the user has installed:
Android app
Windows MSIX
PWA
open
User clicks "open document"
…
install
User on the marketing site
…
const installed = await navigator.getInstalledRelatedApps();
const native = installed.find(a => a.platform === "play"
|| a.platform === "windows");
if (native) {
// Deep-link into the platform app
location.href = native.url + "?doc=" + id;
} else if (installed.find(a => a.platform === "webapp")) {
// Trust PWA install
location.href = "/app/document/" + id;
} else {
// Promote install
showInstallSheet();
}
see also
- Get Installed Related Apps API — feature index
- WICG spec