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

React Native深度链接跳转报No Activity found to handle Intent错误

问题原因

报错由两个核心问题叠加导致:

  1. 原生端未注册深度链接scheme:Android系统找不到可以响应example://协议的Activity,直接抛出No Activity found to handle Intent的系统级错误,这是触发报错的首要原因。
  2. React Navigation linking配置层级错误:你的页面存在两层导航嵌套——Notifications页面属于SignedInStack栈导航,SignedInStack本身又是Drawer导航下的子屏幕,但原配置直接将Notifications写在根screens节点下,即使应用能被URL唤起,导航系统也无法定位到目标页面。
  3. 额外的路径不匹配问题:你调用的URL是example://app/notifications,原配置既没有定义app段的host映射,也没有对齐嵌套路径规则。
修复方案

按以下顺序调整配置:

1. 补全Android原生配置

打开android/app/src/main/AndroidManifest.xml,找到MainActivity节点,调整launchMode并新增深度链接对应的intent-filter:

<activity
  android:name=".MainActivity"
  android:launchMode="singleTask"
  >
  <!-- 原有启动页intent-filter保留 -->
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
  <!-- 新增深度链接配置 -->
  <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- 匹配 example://app/ 开头的链接 -->
    <data android:scheme="example" android:host="app" />
  </intent-filter>
</activity>

注意:修改完原生配置必须重新执行npx react-native run-android重装应用,热更新不会加载manifest改动。
iOS端需要在Info.plist的URL types节点下新增URL Scheme为example的配置,否则iOS端同样无法响应协议。

2. 修正linking配置的嵌套层级

严格对齐导航的嵌套结构改写config配置,修改App.js如下:

const App = () => (
  <NavigationContainer linking={{
    prefixes: ['example://'],
    config: {
      screens: {
        // 根层为Drawer导航下的屏幕
        SignedInStack: {
          // 第二层为Stack导航下的屏幕
          screens: {
            Confluence: 'confluence',
            QRCode: 'qrcode',
            // 匹配路径 example://app/notifications
            Notifications: 'notifications',
          }
        }
      },
    },
  }}>
    <DrawerMenu />
  </NavigationContainer>
);

3. 验证测试逻辑

上述配置完成后,你原有useEffect里的调用代码不需要修改,执行后会正常跳转到Notifications页面:

useEffect(() => {
  Linking.openURL('example://app/notifications');
}, []);

如果不需要URL里带app段,可以将调用URL改为example://notifications,同时把AndroidManifest里data节点的android:host="app"改为android:host="*"即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.28 10:24:21