You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置Deep Link实现example.com链接跳转对应页面并传参?

解决React Native HTTP/HTTPS Deep Link跳转LIVE页面问题

1. 调整App.js的Deep Link路由映射

当前你的LIVE页面映射路径与目标链接不匹配,需修改路由规则,让example.com/m/{uuid}对应到LIVE页面,同时确保根路径跳转HOME:

const deepLinking = {
  prefixes: ['https://www.example.com','https://*.example.com','http://www.example.com','app://'],
  config: {
    initialRouteName:'HOME',
    screens: {
      HOME: '', // 根路径(example.com)对应HOME页面
      LIVE: 'm/:uuid', // 匹配/m/{uuid}格式的链接
      TAGList: 'tag/:enVal'
    }
  },
  getInitialURL
}

2. 完善AndroidManifest.xml的Intent Filter

补充路径匹配规则,确保Android系统能捕获根路径和/m/开头的链接:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <data android:scheme="app" />
  <!-- 匹配根路径链接 -->
  <data android:scheme="https" android:host="www.example.com" android:path="/" />
  <data android:scheme="http" android:host="www.example.com" android:path="/" />
  <data android:scheme="https" android:host="example.com" android:path="/" />
  <data android:scheme="http" android:host="example.com" android:path="/" />
  <!-- 匹配/m/开头的带参链接 -->
  <data android:scheme="https" android:host="www.example.com" android:pathPattern="/m/.*" />
  <data android:scheme="http" android:host="www.example.com" android:pathPattern="/m/.*" />
  <data android:scheme="https" android:host="example.com" android:pathPattern="/m/.*" />
  <data android:scheme="http" android:host="example.com" android:pathPattern="/m/.*" />
</intent-filter>

3. 测试验证

  • 根链接测试:执行npx uri-scheme open "https://example.com" --android,应打开HOME页面
  • 带参链接测试:执行npx uri-scheme open "https://example.com/m/3a35ed925895A26" --android,应打开LIVE页面,且可通过route.params.uuid获取参数

注意事项

修改AndroidManifest.xml后必须重新编译项目(执行npx react-native run-android),配置才能生效。

内容的提问来源于stack exchange,提问作者Mohammad Akbari

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 22:39:25