深度链接

App Links、soar:// scheme 以及通过门禁栈解析路由。

模板同时支持自定义 soar:// scheme 和已验证的 HTTPS App Links。所有进入应用的链接都会 经过同一个 resolver,然后外层导航打开 modal destination,或把 URI 转发进 tab shell。

提供什么

Surface状态实现
Custom schemeIntegratedAndroidManifest.xml 接收 soar://...
Supabase callbackIntegratedsoar://auth-callback 保留给 supabase-kt
HTTPS App LinksIntegratedLINKING_DOMAIN manifest placeholder + Android asset links
冷启动和热启动IntegratedMainActivity.onCreate()onNewIntent() 都调用 DeepLinkHandler
Refer share sheetExampleReferScreen 通过 ACTION_SEND 分享 Play Store URL

关键文件

入口渠道

manifest 声明了三类相关的 ACTION_VIEW filter:

LinkOwner说明
soar://auth-callbackSupabase Auth用于 OTP、recovery、OAuth callback;DeepLinkHandler 会忽略
soar://homesoar://todosApp router应用内页面的 custom scheme link
https://<LINKING_DOMAIN>/homeApp router域名设置完成后的 verified App Links

local.properties 设置 HTTPS host:

LINKING_DOMAIN=example.com

Gradle 会把它注入 manifest 的 ${linkingDomain}。缺失时 placeholder 回退到 your.domain.example;自定义 soar:// 链接仍然可用。

HTTPS App Links 需要在域名上托管 Asset Links 文件:

https://<LINKING_DOMAIN>/.well-known/assetlinks.json

它必须包含最终 application id 和已安装构建所用签名证书的 SHA-256 指纹:

[
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "com.soarstarter.kotlin",
      "sha256_cert_fingerprints": ["AA:BB:CC:..."]
    }
  }
]

生产链接使用 release upload 证书或 Play app-signing 证书。debug 指纹只会验证 debug 构建。

捕获流程

ACTION_VIEW Intent
  -> MainActivity.onCreate() / onNewIntent()
  -> DeepLinkHandler.pendingUri
  -> DeepLinkResolver.resolve(uri, BuildConfig.LINKING_DOMAIN)
  -> AppNavGraph outer destinations or MainShellScreen tab destinations

DeepLinkHandlerStateFlow 中保存一个 pending URI。AppNavGraph 读取后会调用 consume(),避免同一个链接被处理两次。

DeepLinkResolver 接受:

  • soar://home
  • soar:///home
  • soar://anything?route=home
  • https://<LINKING_DOMAIN>/home

route query parameter 会覆盖 path,和 Expo sibling 的 deep-link 行为保持一致。

可路由 destination

DeepLinkDestination 当前包含:

URI segmentDestination处理方式
空或 homeHomeHome tab
componentcomponentsComponentComponent tab
showcaseShowcaseShowcase tab;可移除 leaf
todosTodosHome tab,然后 AppRoutes.Todos
meMeMe tab
profilePersonalInfoMe tab,然后 personal-info screen
notificationsNotificationsMe tab,然后 notifications screen
permissionsPermissionsMe tab,然后 permissions screen
referRefer外层 nav destination
paywallPaywall外层 nav destination
redeem-codeRedeemCode外层 nav destination

ReferPaywallRedeemCode 会先由 AppNavGraph 处理,不进入 shell。其余链接会作为 shellDeepLinkUri 转发,在 MainShellScreen 内处理。

测试链接

对已安装构建运行 adb

adb shell am start \
  -a android.intent.action.VIEW \
  -d "soar://notifications" \
  com.soarstarter.kotlin

Asset Links 验证后测试 HTTPS 形式:

adb shell am start \
  -a android.intent.action.VIEW \
  -d "https://example.com/paywall" \
  com.soarstarter.kotlin

测试推送点击时,可发送:

{ "url": "soar://notifications" }

Refer screen 关联

ReferScreen 不生成自定义 referral code。它会根据 package name 构造 Play Store URL:

https://play.google.com/store/apps/details?id=<package-name>

然后通过 Intent.ACTION_SEND 打开 Android share sheet。把它当作 starter pattern:如果邀请是 你的产品功能,可以把 getInviteLink() 替换为 referral、branch 或 campaign URL。

相关页面

On this page