Hi,
I’m trying to use Branch, and I’ve got it at least to the point where it opens the app, standalone, on Android. Built via exp build.
But nothing happens, and I had a look at logcat, which says:
10-18 23:15:07.278 31433 31433 E g : java.lang.ClassNotFoundException: abi21_0_0.host.exp.exponent.modules.api.branch.RNBranchModule
10-18 23:15:07.278 31433 31433 E g : Runtime exception in RNObject: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.reflect.Method[] java.lang.Class.getMethods()' on a null object reference
Before that it also says
10-18 23:15:06.724 15229 15229 W cr_GoogleAuth: Bad URI 'intent://open?link_click_id=309<redacted>234087#Intent;scheme=myappScheme://+;package=com.mycompany.mypackage;S.browser_fallback_url=https%3A%2F%2Fsomefallbacksite.com%3F_branch_match_id%3D30<redacted>34087;S.market_referrer=link_click_id-3098<redacted>87;B.branch_intent=true;end'
10-18 23:15:06.733 1206 2064 I ActivityManager: START u0 {act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=myappScheme: flg=0x10000000 pkg=com.mycompany.mypackage cmp=com.mycompany.mypackage/host.exp.exponent.LauncherActivity (has extras)} from uid 10093 pid 15229 on display 0
Although not sure if related.
I added the following code, alternately in plain App.js and in componentDidMount deeper inside:
Tried in App.js:
DangerZone.Branch.subscribe((bundle) => {
if (bundle && bundle.params && !bundle.error) {
Alert.alert('Opened Branch link', JSON.stringify(bundle.params, null, 2));
}
});
Tried where I wanted it to be:
this.unsubscribeFromBranch = DangerZone.Branch.subscribe(({ error, params }) => {
if (error) {
console.error(`Error from Branch: ${error}`);
return;
}
console.log(`Branch params: ${JSON.stringify(params)}`);
if (!params['+clicked_branch_link']) return;
// Get title and url for route
// const title = params.$og_title;
const url = params.$canonical_url;
this.setState({ branch: JSON.stringify(params) });
// const image = params.$og_image_url;
// Now push the view for this URL
// this.navigator.push({ title, url, image }); // ??????????
const navigationAction = NavigationActions.navigate({ routeName: url, params });
this.props.dispatch(navigationAction);
});
I’m not sure where to go from here. Do you have any working examples, or some hints at what to do?
In a related note, the Linking.initialUrl is never myscheme://<whatever>
unless I launch a link with just myscheme://?<something>=<something>
specifically with a question-mark and no, well, uri, just queryparams. Is this also expected?
Best regards,
Aslak