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

React Native 0.65本地调试DeepLinking及推荐奖励系统方法咨询

AppsFlyer默认生成的是生产包链接,调试时需要针对debug包调整参数:

  • 将链接中的应用标识替换为本地debug包的Bundle ID(iOS)或包名(Android),比如iOS debug包通常用com.yourapp.debug,Android同理
  • 链接格式示例:yourappscheme://?pid=deep_link&referrer_id=你的推荐者ID,其中yourappscheme是你配置的URL Scheme,referrer_id为自定义的推荐者参数

二、本地环境DeepLink配置补全

生产环境配置生效不代表debug环境无需调整,需针对性检查:

iOS端

  1. 打开Xcode项目的Info标签页,确认URL Types中已添加debug包Bundle ID对应的URL Scheme
  2. 确保Info.plist中包含AppsFlyer调试所需配置,比如NSUserTrackingUsageDescription(如需)
  3. 调试触发方式:用Xcode启动debug包后,在Safari输入调试链接,或用命令行直接唤起:
xcrun simctl openurl booted yourappscheme://?pid=deep_link&referrer_id=123

Android端

  1. 打开AndroidManifest.xml,在主activity标签内确认debug包的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" />
    <data android:scheme="yourappscheme" />
</intent-filter>
  1. 调试触发方式:用Android Studio启动debug包后,通过命令行发送DeepLink:
adb shell am start -W -a android.intent.action.VIEW -d "yourappscheme://?pid=deep_link&referrer_id=123" com.yourapp.debug

三、应用内获取推荐者ID参数

在React Native代码中,确保debug模式下能正常捕获DeepLink参数:

  1. 初始化AppsFlyer时开启调试模式:
import AppsFlyer from 'react-native-appsflyer';

AppsFlyer.initSdk(
  {
    devKey: '你的AppsFlyer DevKey',
    isDebug: true, // 开启调试模式
    appId: '你的应用ID',
  },
  (result) => console.log('初始化成功:', result),
  (error) => console.error('初始化失败:', error)
);
  1. 监听DeepLink回调(热启动场景):
AppsFlyer.onDeepLink((res) => {
  if (res.data?.referrer_id) {
    const referrerId = res.data.referrer_id;
    // 处理推荐者ID逻辑,比如存储到本地
    console.log('推荐者ID:', referrerId);
  }
});
  1. 冷启动场景获取参数:
// Function组件用useEffect
useEffect(() => {
  AppsFlyer.getDeepLinkData((data) => {
    if (data?.referrer_id) {
      console.log('冷启动获取推荐者ID:', data.referrer_id);
    }
  });
}, []);

// Class组件在componentDidMount中调用
componentDidMount() {
  AppsFlyer.getDeepLinkData((data) => {
    if (data?.referrer_id) {
      console.log('冷启动获取推荐者ID:', data.referrer_id);
    }
  });
}

四、调试验证步骤

  1. 生成符合debug包标识的DeepLink链接,确认包含referrer_id参数
  2. 用开发工具启动debug包到模拟器/真机
  3. 通过浏览器或命令行唤起DeepLink,确认应用正常打开
  4. 查看控制台日志,验证推荐者ID参数是否成功获取

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 19:12:23