But this doesn’t work for me when I follow: React Native
I have to add:
pod 'react-native-branch', path: '../node_modules/react-native-branch'
pod 'Branch-SDK', path: '../node_modules/react-native-branch/ios'
And then my compiler complains because I have two versions of Branch. One provided by ExpoKit and another provided by Branch-SDK. But I need to be using the Branch-SDK one. Any ideas how I can force a specific pod to be used?
So I’ve been working on getting Branch to work by following the Branch guide: React Native
I have got it so that if you go to a branch link it will open my app. But I need Branch to pass some parameters to my app. This is where things fail.
The problem I face is that my subscriber never gets called on iOS and Android. Its unclear to me if I should be following all of the Branch steps because I think Expo should take care of some of the setup via the BranchManager.java and I don’t have to initialize branch. Or do I? I’m referring to these steps: React Native
I’m trying avoid having two versions of Branch in my app. This should be working with ExpoKit.
import { DangerZone } from "expo";
const branch = DangerZone.Branch;
const run = async () => {
branch.subscribe(({ error, params }) => {
console.info("branch test");
console.info({ error });
console.info({ params });
if (error) {
console.error("Error from Branch: " + error);
return;
}
// params will never be null if error is null
if (params["+non_branch_link"]) {
const nonBranchUrl = params["+non_branch_link"];
// Route non-Branch URL if appropriate.
return;
}
if (!params["+clicked_branch_link"]) {
// Indicates initialization success and some other conditions.
// No link was opened.
return;
}
// A Branch link was opened.
// Route link based on data in params.
});
console.info("params");
const lastParams = await branch.getLatestReferringParams(); // params from last open
console.info({ lastParams });
const installParams = await branch.getFirstReferringParams(); // params from original install
console.info({ installParams });
};
run();
I was able to get this working by importing from DangerZone and copying in the example subscribe code, after I performed the AndroidManifest / Info.plist / entitlements steps linked in the react-native-branch documentation. Didn’t need to do modify any actual native code.