[英]React native android app not getting branch referral data after play store install
We have a react native app, compiled into both android and ios. 我们有一个React Native应用程序,已编译为android和ios。 We are using branch.io to track installs via different links and route the user to different places. 我们正在使用branch.io通过不同的链接跟踪安装,并将用户路由到不同的地方。 The ios app works great in all scnearios. ios应用程序可在所有场景中正常运行。
For the android app, it works in every test case listed on the site (most of which are install the app but don't open it, then click the link, or vice versa), but when the link directs the user to the play store, and they download it from there, the link is not working. 对于android应用程序,它可以在网站上列出的每个测试用例中使用(大多数情况下都安装了该应用程序,但未打开它,然后单击链接,反之亦然),但是当链接将用户定向到播放时商店,然后他们从那里下载该链接,则该链接无法正常工作。
I have seen 3 cases 1. It works fine (rare) 2. It doesn't work at all, and no data comes through 3. Params come through as +clicked_branch_link:false +is_first_session:true
我见过3种情况1.正常工作(很少)2.根本不工作,没有数据通过3.参数通过+clicked_branch_link:false +is_first_session:true
I am using the latest version of react-native-branch from npm 我正在使用npm的最新版本的react-native-branch
So far, email support from branch has been unresponsive, and the one response I received was of no help 到目前为止,来自分支机构的电子邮件支持一直没有响应,我收到的一个回复没有帮助。
In order for all deep linking edge cases to work, you need to confirm that: 为了使所有深层链接边缘案例都能正常工作,您需要确认:
1) You import the Branch packages into your MainApplication.java
1)您将Branch包导入到MainApplication.java
import io.branch.rnbranch.RNBranchPackage;
import io.branch.referral.Branch;
2) Add RNBranchPackage to the package list in MainApplication.java
2)添加RNBranchPackage在软件包列表MainApplication.java
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNBranchPackage(), // <-- add this
3) Override onCreate() in MainApplication.java
3)在MainApplication.java
重写onCreate()
@Override
public void onCreate() {
super.onCreate();
Branch.getAutoInstance(this);
}
4) Import Branch into your MainActivity
: 4)将Branch导入到您的MainActivity
:
import io.branch.rnbranch.*;
import android.content.Intent;
5) Branch is initialized in the onStart()
of your MainActivity
: 5)在您的MainActivity
的onStart()
中初始化分支:
protected void onStart() {
super.onStart();
RNBranchModule.initSession(getIntent().getData(), this);
}
6) onNewIntent()
is overidden in the MainActivity
: 6) onNewIntent()
在MainActivity
被覆盖:
@Override
public void onNewIntent(Intent intent) {
setIntent(intent);
}
Note that this is under the assumption your MainActivity
is the main launcher activity. 请注意,这是基于您的MainActivity
是主要启动器活动的假设。 Please reference: https://docs.branch.io/pages/apps/react-native/#android_1 请参考: https : //docs.branch.io/pages/apps/react-native/#android_1
For reference, I was using react-native-branch v2.2.4 from NPM 作为参考,我使用了NPM的react-native-branch v2.2.4
I tested the following cases: 我测试了以下情况:
[Works] Click the branch link then install the app [Works]单击分支链接,然后安装应用程序
[Works] Install the app from an APK but don't open it, then click the link [Works]从APK安装应用程序,但不打开它,然后单击链接
Turns out, the issue was resolved by removing the following lines from the AndroidManifest.xml 原来,通过从AndroidManifest.xml中删除以下几行来解决了该问题
<!-- Branch install referrer tracking (optional) -->
<receiver android:name="io.branch.referral.InstallListener" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.