有时Branch在init上从其服务器返回空json.这是非常随机的,对于相同的url分支响应可能是也可能不是空的.
Branch branch = Branch.getInstance(); branch.initSession(new Branch.BranchReferralInitListener() { @Override public void onInitFinished(final JSONObject referringParams,final BranchError error) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { runningOnUIThread(referringParams,error); } }); Log.d("BRANCH IO",referringParams.toString()); } },a.getIntent().getData(),a);
referParams:可能是{}或正确的数据.知道为什么会发生这种情况吗?
解决方法
开发环境:
将TestMode设置为“true”以模拟开发环境中的全新安装.
<Meta-data android:name="io.branch.sdk.TestMode" android:value="true" />
配置您的iOS / Android应用
Android:https://docs.branch.io/pages/apps/android/
IOS:https://docs.branch.io/pages/apps/ios/
可选的:
– 确保已在仪表板控制台中正确配置了分支io链接设置.
– 使用链接管理中的params列表中定义的正确密钥名称获取params.
JSONObject sessionParams = Branch.getInstance().getLatestReferringParams(); sessionParams.has("paramName")
启动分支会话:
Branch branch = Branch.getInstance(); // Branch init branch.initSession(new Branch.BranchReferralInitListener() { @Override public void onInitFinished(JSONObject referringParams,BranchError error) { if (error == null) { Log.e("BRANCH SDK",referringParams.toString()); // latest JSONObject sessionParams = Branch.getInstance().getLatestReferringParams(); Log.e("sessions params :",sessionParams.toString()); // first JSONObject installParams = Branch.getInstance().getFirstReferringParams(); Log.e("install params :",installParams.toString()); processDeepLinkParams(sessionParams); if (getIntent().getExtras() != null && getIntent().getExtras().keySet() != null) { deepLinkinData = getIntent().getExtras().getString("branch_data"); } // Branch logging for debugging // Branch.enableLogging(); } else { Log.i("BRANCH SDK",error.getMessage()); } } },this.getIntent().getData(),this);