Philberg
Philberg

Reputation: 640

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. We are using branch.io to track installs via different links and route the user to different places. The ios app works great in all scnearios.

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.

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

I am using the latest version of react-native-branch from npm

So far, email support from branch has been unresponsive, and the one response I received was of no help

Upvotes: 5

Views: 1961

Answers (2)

Philberg
Philberg

Reputation: 640

For reference, I was using react-native-branch v2.2.4 from NPM

I tested the following cases:

  1. [Works] Click the branch link then install the app

  2. [Works] Install the app from an APK but don't open it, then click the link

  3. [Works] Install the app from the store THEN click the link
  4. [Broken] Click the link to install through the app store

Turns out, the issue was resolved by removing the following lines from the 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>

Upvotes: 1

aaron
aaron

Reputation: 381

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

import io.branch.rnbranch.RNBranchPackage;
import io.branch.referral.Branch;

2) Add RNBranchPackage to the package list in MainApplication.java

@Override
  protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new RNBranchPackage(), // <-- add this

3) Override onCreate() in MainApplication.java

@Override
public void onCreate() {
  super.onCreate();
  Branch.getAutoInstance(this);
}

4) Import Branch into your MainActivity:

import io.branch.rnbranch.*;
import android.content.Intent;

5) Branch is initialized in the onStart() of your MainActivity:

protected void onStart() {
          super.onStart();
          RNBranchModule.initSession(getIntent().getData(), this);
      }

6) onNewIntent() is overidden in the MainActivity:

@Override
      public void onNewIntent(Intent intent) {
          setIntent(intent);
      }

Note that this is under the assumption your MainActivity is the main launcher activity. Please reference: https://docs.branch.io/pages/apps/react-native/#android_1

Upvotes: 0

Related Questions