public static void initSession(Uri uri, ReactActivity reactActivity) { Branch branch = Branch.getInstance(); branch.initSession(new Branch.BranchReferralInitListener(){ private ReactActivity mActivity = null; @Override public void onInitFinished(JSONObject referringParams, BranchError error) { Log.d(REACT_CLASS, "onInitFinished"); JSONObject result = new JSONObject(); try{ result.put("params", referringParams != null ? referringParams : JSONObject.NULL); result.put("error", error != null ? error.getMessage() : JSONObject.NULL); } catch(JSONException ex) { try { result.put("error", "Failed to convert result to JSONObject: " + ex.getMessage()); } catch(JSONException k) {} } initSessionResult = result; LocalBroadcastManager.getInstance(mActivity).sendBroadcast(new Intent(NATIVE_INIT_SESSION_FINISHED_EVENT)); } private Branch.BranchReferralInitListener init(ReactActivity activity) { mActivity = activity; return this; } }.init(reactActivity), uri, reactActivity); }