链接、深层链接、Android 应用链接和 iOS 通用链接概述
关于在你的 Expo 应用中实现链接和深层链接的可用资源的概述。
链接
🌐 Linking
Linking 允许你的应用与传入和传出的 URL 进行交互。在此过程中,用户不仅会被引导打开你的应用,还会被带到应用中的特定界面(路由)。
🌐 Linking allows your app to interact with incoming and outgoing URLs. In this process, the user not only gets directed to open your app, but they are taken to a specific screen (route) within the app.

链接策略
🌐 Linking strategies
你在 Expo 应用中处理不同的链接策略:
🌐 There are different linking strategies you handle in your Expo app:
- 使用你的网站域名链接将你的应用链接起来(使用
https或http方案的通用链接) - 使用自定义方案(深层链接)从其他应用或网站链接到你的应用
- 从你的应用链接到其他应用(传出链接)
信息 提示: Expo Go 对传入链接的支持有限。我们建议使用 开发构建 来测试你的应用链接策略。
更新底部选项卡导航器外观
🌐 Universal linking
Android 和 iOS 都实现了将网页 URL 路由到已安装应用的系统。在 Android 上,这个系统叫做 App Links,而在 iOS 上,它叫做 Universal Links。这两个系统的前提条件是你拥有一个可以托管文件的网页域名,通过这个文件可以验证你对该域名的控制权。
🌐 Both Android and iOS implement their own systems for routing web URL's to an app if the app is installed. On Android, this system is called App Links, and on iOS it is called Universal Links. The pre-requisite for both systems is that you have a web domain where you can host a file which verifies you control the domain.
安卓应用链接
🌐 Android App Links
Android 应用链接不同于标准深度链接,因为它们使用常规的 HTTP 和 HTTPS 协议,并且仅适用于 Android 设备。
🌐 Android App Links are different from standard deep links as they use regular HTTP and HTTPS schemes and are exclusive to Android devices.
这种链接类型可以让当用户点击链接时总是打开你的应用,而不是在设备上显示的对话框中选择浏览器或其他处理程序。如果用户没有安装你的应用,链接会将他们引导到你的应用关联的网站。
🌐 This link type allows your app to always open when a user clicks the link instead of choosing between the browser or another handler from a dialog displayed on the device. If the user doesn't have your app installed, the link takes them to your app's associated website.
了解如何配置 intentFilters 并从标准网页 URL 设置双向关联。
iOS 通用链接
🌐 iOS Universal Links
iOS 通用链接不同于标准深度链接,因为它们使用常规的 HTTP 和 HTTPS 方案,并且仅限于 iOS 设备。
🌐 iOS Universal Links are different from standard deep links as they use regular HTTP and HTTPS schemes and are exclusive to iOS devices.
此链接类型允许用户点击指向你的网站域名的 HTTP(S) 链接时打开你的应用。如果用户未安装你的应用,链接会将他们引导至你应用的关联网站。你还可以通过使用 Apple 智能横幅 为用户显示横幅,从而进一步配置网站以打开你的应用。
🌐 This link type allows your app to open when a user clicks an HTTP(S) link pointing to your web domain. If the user doesn't have your app installed, the link takes them to your app's associated website. You can further configure the website by displaying a banner for the user to open your app using Apple Smart Banner.
了解如何配置 associatedDomains 并设置双向关联。
从其他应用链接到你的应用或网站
🌐 Linking to your app from other apps or websites
深度链接 是指链接到应用或网站内特定 URL 内容的链接。
例如,通过点击一个产品广告,你的应用将在用户的设备上打开,他们可以查看该产品的详细信息。用户点击的该产品链接可能看起来像这样(或者可以通过设置 window.location.href 的 JavaScript 调用):
🌐 For example, by clicking a product advertisement, your app will open on the user's device and they can view that product's details. This product's link that the user clicked may look like (or alternatively be invoked by JavaScript with setting window.location.href):
<a href="myapp://web-app.com/product">View Product</a>
此链接由三部分构成:
🌐 This link is constructed by three parts:
- Scheme:用于标识应该打开该 URL 的应用的 URL 方案(示例:
myapp://)。对于非标准深层链接,它也可以是https或http。我们建议对于基于 http(s) 的深层链接使用通用链接。 - 主机:应该打开该 URL 的应用的域名(例如:
web-app.com)。 - 路径:要打开的屏幕的路径(例如:
/product)。如果未指定路径,用户将进入应用的主屏幕。
学习如何配置自定义 URL 方案,以创建应用的深度链接。
使用配置插件进行原生项目配置
🌐 Use Expo Router to handle deep linking
要实现上述任何一种链接策略,我们建议使用 Expo Router,因为它会自动为你应用的所有屏幕启用深度链接。
🌐 To implement any of the above Linking strategies, we recommend using Expo Router since deep linking is automatically enabled for all of your app's screens.
好处:
- Expo Router 的
Link组件可用于 处理到其他应用的 URL 方案 - Android 应用链接和 iOS 通用链接需要在 JavaScript 中为应用中的链接配置运行时路由。使用 Expo Router 时,你无需单独配置运行时路由,因为所有路由的深层链接会自动启用。
- 对于第三方深度链接,你可以覆盖默认的链接行为来处理传入的链接并发送导航事件。请参见 自定义链接。
从你的应用链接到其他应用
🌐 Linking to other apps from your app
从你的应用链接到其他应用是通过基于目标应用 URL 方案的 URL 实现的。这个 URL 方案 允许你引用该原生应用内的资源。
🌐 Linking to other apps from your app is achieved using a URL based on the target app's URL scheme. This URL scheme allows you to reference resources within that native app.
你的应用可以使用常用 URL 方案来作为默认应用,包括 https 和 http(通常由像 Chrome、Safari 等网页浏览器使用),并使用 JavaScript 调用启动对应原生应用的 URL。
🌐 Your app can use a common URL scheme for default apps, including https and http (commonly used by web browsers like Chrome, Safari, and so on), and use JavaScript to invoke the URL that launches the corresponding native app.
学习如何处理常见和自定义的 URL 方案,以便从你的应用链接到其他应用。