React Native 0.65本地调试DeepLinking及推荐奖励系统方法咨询
React Native 0.65 本地调试AppsFlyer DeepLink 方案
一、生成本地调试专用DeepLink
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端
- 打开Xcode项目的
Info标签页,确认URL Types中已添加debug包Bundle ID对应的URL Scheme - 确保
Info.plist中包含AppsFlyer调试所需配置,比如NSUserTrackingUsageDescription(如需) - 调试触发方式:用Xcode启动debug包后,在Safari输入调试链接,或用命令行直接唤起:
xcrun simctl openurl booted yourappscheme://?pid=deep_link&referrer_id=123
Android端
- 打开
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>
- 调试触发方式:用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参数:
- 初始化AppsFlyer时开启调试模式:
import AppsFlyer from 'react-native-appsflyer'; AppsFlyer.initSdk( { devKey: '你的AppsFlyer DevKey', isDebug: true, // 开启调试模式 appId: '你的应用ID', }, (result) => console.log('初始化成功:', result), (error) => console.error('初始化失败:', error) );
- 监听DeepLink回调(热启动场景):
AppsFlyer.onDeepLink((res) => { if (res.data?.referrer_id) { const referrerId = res.data.referrer_id; // 处理推荐者ID逻辑,比如存储到本地 console.log('推荐者ID:', referrerId); } });
- 冷启动场景获取参数:
// 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); } }); }
四、调试验证步骤
- 生成符合debug包标识的DeepLink链接,确认包含
referrer_id参数 - 用开发工具启动debug包到模拟器/真机
- 通过浏览器或命令行唤起DeepLink,确认应用正常打开
- 查看控制台日志,验证推荐者ID参数是否成功获取
内容的提问来源于stack exchange,提问作者Mlikaon
相关产品推荐
相关产品推荐

