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

Expo React Native Deeplink配置问题:无法通过链接打开应用

Expo Deeplink跳转异常解决方案

1. 修正app.json的scheme配置

要把scheme配置在app.json的expo字段内,不要加://,只写纯标识字符串,避免配置位置错误或格式冗余,正确示例:

{
  "expo": {
    "scheme": "testapp",
    // 其他项目配置...
  }
}

2. 调整NavigationContainer的linking前缀

你当前的前缀多嵌套了一层testapp,直接用testapp://作为基础前缀即可;另外exp://链接需要替换成你项目实际的开发服务器地址(启动expo start后控制台会显示该地址),示例代码:

import { NavigationContainer } from '@react-navigation/native';

const linking = {
  prefixes: ['testapp://', 'exp://your-expo-username/your-project-slug'],
  // 若需路径匹配规则,可补充config配置
};

export default function App() {
  return (
    <NavigationContainer linking={linking} fallback={<Text>Loading...</Text>}>
      {/* 你的导航栈代码 */}
    </NavigationContainer>
  );
}

3. Android Studio裸项目的额外配置

如果是用Android Studio运行裸项目(而非Expo Go),需要在AndroidManifest.xml的MainActivity标签内添加intent-filter,让系统识别你的scheme:

<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="testapp" />
</intent-filter>

配置完成后必须重新构建项目,热重载不会生效。

4. Expo Go的正确测试方式

  • 确保Expo Go与开发服务器处于同一网络环境;
  • 不要直接在浏览器输入链接(浏览器会优先解析为搜索词),应在邮件、备忘录等APP中点击链接,或通过系统分享功能打开;
  • 可手动构造如testapp://home的带路径链接,点击后应唤起Expo Go并打开你的项目。

5. 验证scheme是否注册成功

  • Android:使用ADB命令直接测试,能唤起APP则说明配置有效:
adb shell am start -W -a android.intent.action.VIEW -d "testapp://"
  • iOS:在模拟器中通过Safari输入链接,或使用Xcode的URL Scheme测试工具,检查是否能唤起Expo Go。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.29 07:42:22