跳转到主要内容

概览

深度链接允许您从外部来源(如网站、电子邮件或 SMS)打开应用程序中的特定页面。如果未安装应用程序,用户会被重定向到相应的应用商店。如果在不受支持的平台上,用户会被重定向到备用网站。 本指南涵盖以下方面的深度链接设置和使用:
  • Android(应用链接)
  • iOS(通用链接和 URL 方案)
  • 推送通知
  • 电子邮件
  • 应用内消息
要正常运行,深度链接必须:
  • Android 设置
  • iOS 设置

Android 设置

使用 Android Studio 的 App Links Assistant 来简化设置。

步骤:

  1. 打开 Android Studio → 工具App Links Assistant
  2. 按照步骤设置到您网站的链接
  3. Android Studio 自动生成所需的代码和 assetlinks.json 文件

清单示例:

<activity android:name=".SecondActivity" android:exported="true">
  <intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="https" />
    <data android:host="yoursite.com" />
  </intent-filter>
</activity>

Activity 处理器示例:

Intent appLinkIntent = getIntent();
String appLinkAction = appLinkIntent.getAction();
Uri appLinkData = appLinkIntent.getData();
生成的 assetlinks.json 文件必须托管在:
https://yoursite.com/.well-known/assetlinks.json

使用深度链接发送

  • 使用深度链接发送推送通知
  • 使用深度链接发送电子邮件
  • 使用深度链接发送应用内消息
将深度链接包含为:
  • url 属性(启动 URL)
  • data 属性(推荐用于 iOS 以抑制浏览器重定向)
行为:
  • Android:直接打开到链接的活动
  • iOS:打开浏览器,然后是应用程序(除非使用 plist 标志抑制)

I