我已经实现了Branch.io推荐程序。调试模式已启用。当我点击链接时,它会导航到应用程序。在注册成功时,我使用setIdentity(" user_id")方法,然后使用引用者和引用用户的getCredits()和Redeem Credits。它在设备上只工作一次或两次,然后返回返回{在setIdentity上(" user_id")。 有我的代码:
branch.setIdentity(Settings.USERID, new Branch.BranchReferralInitListener() {
@Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (!referrer_id.equalsIgnoreCase("")) {
branch.userCompletedAction("referAFriend");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
branch.loadRewards(new Branch.BranchReferralStateChangedListener() {
@Override
public void onStateChanged(boolean changed, BranchError error) {
if (error == null) {
if (changed) {
credits = branch.getCredits();
Log.e("credits", credits + "");
branch.redeemRewards(credits, new Branch.BranchReferralStateChangedListener() {
@Override
public void onStateChanged(boolean changed, BranchError error) {
branch.logout(new Branch.LogoutStatusListener() {
@Override
public void onLogoutFinished(boolean loggedOut, BranchError error) {
if (loggedOut) {
Log.e("210", loggedOut + "");
if (!referrer_id.equalsIgnoreCase("")) {
Log.e("209",referrer_id+"");
branch.setIdentity(referrer_id, new Branch.BranchReferralInitListener() {
@Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
Log.e("215",referringParams+"");
if(referringParams.toString().equalsIgnoreCase("{}"))
{
Utils.resultdialog(SignupActivity.this, "Registered Successfully.", "signup");
}
else {
if (error == null) {
branch.loadRewards(new Branch.BranchReferralStateChangedListener() {
@Override
public void onStateChanged(boolean changed, BranchError error) {
if (error == null) {
if (changed) {
refreepoints = branch.getCredits();
Log.e("refreepoints", refreepoints + "");
branch.redeemRewards(refreepoints, new Branch.BranchReferralStateChangedListener() {
@Override
public void onStateChanged(boolean changed, BranchError error) {
if (error == null) {
if (changed) {
} else {
}
} else {
Log.e("255", "255");
}
}
}
});
}
} else {
Log.e("265", error + "");
Utils.resultdialog(SignupActivity.this, "Registered Successfully.", "signup");
}
}
});
} else {
Log.e("268", error + "");
}
}
}
});
} else {
Log.e("266", "error");
}
}
}
});
}
});
} else {
Log.e("271", error + "");
}
} else {
Log.e("274", error + "");
}
}
});
}
}, 10000);
} else {
}
}
});