Initializing branch with callback only when Intent data is set

Asked on February 16, 2017 in Technical.

Initializing branch with callback to handle activity routing for all app launches makes app launch from launcher icon slow in case of slow/flaky internet connections.

 branch.initSession(new Branch.BranchReferralInitListener() {
@Override public void onInitFinished(final JSONObject referringParams, BranchError error) {
routeLaunchToReleventActivity(...)
}
} 
What is the recommended strategy to avoid this? What disadvantages are there if I initialize branch without callback, if the Intent doesn’t have any data set i.e. – it is launched via launcher icon not via a link.
 if(this.getIntent().getData() == null) {
routeLaunchToReleventActivity(...)
branch.initSession();
} else {
branch.initSession(new Branch.BranchReferralInitListener() {
@Override public void onInitFinished(final JSONObject referringParams, BranchError error) {
routeLaunchToReleventActivity(...)
}
}
} 
  It enables me properly route links as well as doesn’t slow startup in case of app launches from launcher icon

Plystash — Developer
1 Answer(s)
Answered on February 22, 2017.

Hi Sunil – thanks for posting the question. How much delay are you experiencing in waiting for the callback? What you are doing is correct and the best way to use Branch. If you are facing delays in callbacks, I’d suggest that you create a ticket for our integrations team here.

Developer