Shashika Virajh
Shashika Virajh

Reputation: 9477

Testing Branch.IO referral links on react native

We use branch for referrals in our react native application. I have implemented branch successfully, now I want to test some scenarios.

When we click on a referral link, it navigates to app store or play store. But I want to do some debugging to identify if the params I pass are successfully send or not.

I have subscribed it like this. But how can I debug this with react-native debugger to see the console logs?

BranchIO.subscribe(async ({ error, params }) => {
    if (error) {
      console.log('Error from Branch: ', error);
      return;
    }

    // Handle non-Branch URL.
    if (params['+non_branch_link']) return;

    // Indicates initialization success.
    // No link was opened.
    if (!params['+clicked_branch_link']) return;

    const installParams = await BranchIO.getFirstReferringParams();

    if (installParams?.$canonical_identifier === DeepLinkTypes.referral) {
      store.dispatch(setReferralKey(installParams.referralKey));
    }

    // A Branch link was opened.
    // Route link based on data in params
    navigatePath(params.$deeplink_path);
  });

Upvotes: 2

Views: 1302

Answers (1)

Kartik Shandilya
Kartik Shandilya

Reputation: 3924

To debug if you are able to fetch the associated link data or not you can put in a debugger at the following line-

const installParams = await BranchIO.getFirstReferringParams();

Also we would suggest you to kindly use/update the above line to use getLatestReferringParams

let lastParams = await branch.getLatestReferringParams()

instead of getFirstReferringParams() since there are some recent issues reported lately with this method. You can print out the parameters in the console and see for the link data.

Upvotes: 2

Related Questions