大网数据广告活动
Web 标准与前端开发

Navigator: getInstalledRelatedApps() method

· 52CE 我爱测

The **`getInstalledRelatedApps()`** method returns a promise that resolves with an array of objects representing any related platform-specific apps or Progressive Web Apps that the user has installed. This could be used for content personalization such as removing "install our ap

The getInstalledRelatedApps() method returns a promise that resolves with an array of objects representing any related platform-specific apps or Progressive Web Apps that the user has installed. This could be used for content personalization such as removing "install our app" banners from the web app if the platform-specific app and/or PWA is already installed.

[!NOTE] This method must be invoked in a top-level secure context, that is, not embedded in an iframe.

Syntax

getInstalledRelatedApps()

Parameters

None.

Return value

A Promise that fulfills with an array of objects representing any installed related apps. Each object can contain the following properties:

  • id
    • : A string representing the ID used to represent the application on the specified platform. The exact form of the string will vary by platform.
  • platform
  • url
    • : A string representing the URL associated with the app. This is usually where you can read information about it and install it.
  • version
    • : A string representing the related app's version.

The related app information must have been previously specified in the related_applications member of the invoking web app's manifest file.

Exceptions

  • InvalidStateError DOMException
    • : The method was not invoked in a top-level browsing context.

Description

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:

  1. The invoking web app must be specified in the related_applications member of its manifest file.
  2. The platform-specific app or PWA must have its relationship with the invoking app defined.

Defining the relationship is done in a different way depending on the type of app:

  • An Android app does this via the Digital Asset Links system.
  • A Windows UWP app does this via URI Handlers.
  • A PWA does this via:
    • A self-defining entry inside its own related_applications manifest member, specifying the platform and id properties, in the case of a PWA checking in the same scope if it is installed on the underlying platform.
    • An assetlinks.json file in its /.well-known/ directory in the case of an app outside the scope of the PWA checking whether it is installed on Android.

See Is your app installed? getInstalledRelatedApps() will tell you! for more details on how to handle each one of these cases.

[!NOTE] Most supporting browsers provide their own install UI when an installable PWA is detected, which won't appear if it is already installed — see Making PWAs installable > Installation from the web. This can be suppressed using the Window.beforeinstallprompt_event event, which could also be combined with getInstalledRelatedApps() to suppress it based on a platform-specific app being available. See Trigger installation from your PWA for further useful information.

Examples

const relatedApps = await navigator.getInstalledRelatedApps();

// Dump all the returned related apps into a table in the console
console.table(relatedApps);

// Search for a specific installed platform-specific app
const psApp = relatedApps.find((app) => app.id === "com.example.myapp");

if (psApp && doesVersionSendPushMessages(psApp.version)) {
  // There's an installed platform-specific app that handles sending push messages
  // No need to handle this via the web app
  return;
}

[!NOTE] In this example, doesVersionSendPushMessages() is a theoretical developer-defined function; it is not provided by the browser.

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。