Branch branch = Branch.getInstance();
branch.setRetryCount(1);
branch.setRetryInterval(10);
branch.initSession(new Branch.BranchUniversalReferralInitListener() {
@Override
public void onInitFinished(BranchUniversalObject branchUniversalObject, LinkProperties linkProperties, BranchError branchError) {
当用户网速较慢时,有时不会调用我的onInitFinished。我已经看到该应用程序在尝试初始化分支
时停留超过30秒答案 0 :(得分:4)
目前这是一个众所周知的边缘案例。我们正在修复,但是现在你可以实现如下的超时:
final CountDownLatch countDownLatch = new CountDownLatch(1);
new Thread(new Runnable() {
@Override
public void run() {
branch.initSession(new Branch.BranchUniversalReferralInitListener() {
@Override
public void onInitFinished(BranchUniversalObject branchUniversalObject, LinkProperties linkProperties, BranchError error) {
if(countDownLatch.getCount() > 0) {
countDownLatch.countDown();
postBranchInitSession(null);
}
}
});
try {
countDownLatch.await(5000, TimeUnit.MICROSECONDS);
} catch (InterruptedException ignore) {
postBranchInitSession(null);
}
}
}).run();