reddiky
reddiky

Reputation: 182

Deferred Deep Linking in iOS using Branch.io in a React Native App

We have implemented deferred deep linking in our branch using Branch.io. The flow works correctly in our Android build but not in iOS. When clicking on a deep link in an iOS device the app is correctly installed but the deferred content piece of our deep link is not working. The branch validate gem is all green.

The relevant code is:

branch.subscribe(async ({ error, params, uri }) => {
  if (error) {
    console.error(`Error from Branch: ${error}`);
    return;
  }

  if (params['+non_branch_link']) {
    return;
  }

  if (!params['+clicked_branch_link']) {
    return;
  }

  const deepLink = params.$deeplink_path;
  if (deepLink) {
    Linking.openURL(deepLink).catch((e) => { console.log('[Branch Error]', e); });
  }
});

Upvotes: 0

Views: 2246

Answers (2)

Justin Joy
Justin Joy

Reputation: 383

Did you try to set a initSessionTtl time of about 10 seconds?

componentDidMount() {
    branch.initSessionTtl = 10000;
    branch.subscribe(({ error, params, uri }) => {
        //Handle the deep link here
    });
}

Upvotes: 1

reddiky
reddiky

Reputation: 182

Never was able to solve this with existing paradigm. Ended up just setting state inside of my if block and redirecting the user on the incorrect screen if the state was set. Must be some kind of race condition.

¯\ (ツ)

Upvotes: 1

Related Questions