Branch.io doesn't fetch data on subscribe when the app is already opened

Please provide the following:

  1. SDK Version: 40.0.0
  2. Platforms(Android/iOS/web/all): Android
  3. Tags: Branch.io subscribe

I set up Branch.io successfully and managed to receive the deep linking data when I subscribe on component did mount. For the sake of debugging with release bundle I have screen with Text component which shows the value of testData.

 Branch.subscribe(bundle => {
            this.props.AuthStore.testData = JSON.stringify(bundle);
});

There are 2 scenarios, one working and one not working:

  1. (Working) u don’t open the app → u navigate to some note (or gmail) → click the link → app is opened and the data from the link is being extracted on Branch.subscribe

  2. (NOT working) u open the app → u minimize the app → u navigate to some note (or gmail) → click the link → app opens but the link data is not received and branch.subscribe is not triggered

Is there some configuration that I am missing? I tried subscribing on AppStateChange (foreground|background) + I tried using await Branch.getLatestReferringParams() (without any success in both scenarios)

Please help and thank you for reading, hope this helps other people as well.

Are you using eas build? If so, the only fix I’ve found is reverting to expo build, unfortunately.

https://github.com/expo/expo/issues/12906#issuecomment-845627183

1 Like

Nope, I am generating the app with expo build like this:
expo build:android -t apk --release-channel test

Additionally I can see that subscribe is being called (tested it by adding a counter) but without the required parameters.

As my research shows so far there is this hidden gem functionality (hidden because not mentioned into documentation) called “branch_force_new_session”: true … now I need to set this as an intent, but I have no idea how to do so in app.json

The solution: use Linking from react-native.

Branch fetches the first call when the app is opened. If the app is running in the background the links are being interrupted by different communication layer and Branch.io cannot be reached. Thats how I understood it, it doesn’t mean I am 100% right, this is based on lots of console.logs, builds and debugging.

Therefore you only need to call the branch link handling code. However on the backend, the Branch generated links need to contain the parameters in the URL in order for this to be feasible solution, because you won’t get the object bundle from branch when handling links with the Linking module.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.