@@ -109,6 +109,7 @@ public static void getAutoInstance(Context context) {
109109 public static void reInitSession (Activity reactActivity ) {
110110 Branch branch = Branch .getInstance ();
111111 Intent intent = reactActivity .getIntent ();
112+ Log .d (REACT_CLASS ,"reInitSession intent " + intent );
112113 if (intent != null ) {
113114 intent .putExtra ("branch_force_new_session" , true );
114115 notifyJSOfInitSessionStart (reactActivity , intent .getData ());
@@ -119,11 +120,14 @@ public static void reInitSession(Activity reactActivity) {
119120 }
120121
121122 public static void initSession (final Uri uri , Activity reactActivity , Branch .BranchUniversalReferralInitListener anInitListener ) {
123+ Log .d (REACT_CLASS ,"initSession uri " + uri + " reactActivity " + reactActivity + " anInitListener" + anInitListener );
122124 initListener = anInitListener ;
123125 initSession (uri , reactActivity );
124126 }
125127
126128 public static void initSession (final Uri uri , Activity reactActivity ) {
129+ Log .d (REACT_CLASS ,"initSession uri " + uri + " reactActivity " + reactActivity );
130+
127131 Branch branch = setupBranch (reactActivity .getApplicationContext ());
128132
129133 mActivity = reactActivity ;
@@ -134,6 +138,8 @@ public static void initSession(final Uri uri, Activity reactActivity) {
134138
135139 @ Override
136140 public void onInitFinished (JSONObject referringParams , BranchError error ) {
141+ Log .d (REACT_CLASS ,"onInitFinished referringParams " + referringParams );
142+
137143 // react native currently expects this to never be null
138144 if (referringParams == null ) {
139145 referringParams = new JSONObject ();
@@ -148,14 +154,15 @@ public void onInitFinished(JSONObject referringParams, BranchError error) {
148154 result .put (NATIVE_INIT_SESSION_FINISHED_EVENT_URI , isNewIntent && uri != null ? uri .toString () : JSONObject .NULL );
149155 }
150156 catch (JSONException e ) {
151-
157+ Log . e ( REACT_CLASS , e . getMessage ());
152158 }
153159 initSessionResult = result ;
154160
155161 BranchUniversalObject branchUniversalObject = BranchUniversalObject .getReferredBranchUniversalObject ();
156162 LinkProperties linkProperties = LinkProperties .getReferredLinkProperties ();
157163
158164 if (initListener != null ) {
165+ Log .d (REACT_CLASS ,"onInitFinished " + branchUniversalObject + " " + linkProperties + " error " +error );
159166 initListener .onInitFinished (branchUniversalObject , linkProperties , error );
160167 }
161168 generateLocalBroadcast (referringParams , uri , branchUniversalObject , linkProperties , error );
@@ -171,6 +178,7 @@ private void generateLocalBroadcast(JSONObject referringParams,
171178 BranchUniversalObject branchUniversalObject ,
172179 LinkProperties linkProperties ,
173180 BranchError error ) {
181+
174182 Intent broadcastIntent = new Intent (NATIVE_INIT_SESSION_FINISHED_EVENT );
175183
176184 if (referringParams != null ) {
@@ -202,7 +210,10 @@ private void generateLocalBroadcast(JSONObject referringParams,
202210 }.init (reactActivity );
203211
204212 notifyJSOfInitSessionStart (reactActivity , uri );
205- Branch .sessionBuilder (reactActivity ).withCallback (referralInitListener ).withData (uri ).init ();
213+
214+ Branch .InitSessionBuilder initSessionBuilder = Branch .sessionBuilder (reactActivity ).withCallback (referralInitListener ).withData (uri );
215+ Log .d (REACT_CLASS , "sessionBuilder " + initSessionBuilder );
216+ initSessionBuilder .init ();
206217 }
207218
208219 /**
@@ -215,6 +226,7 @@ private void generateLocalBroadcast(JSONObject referringParams,
215226 * @param intent the new Intent received via Activity.onNewIntent
216227 */
217228 public static void onNewIntent (@ Nonnull Intent intent ) {
229+ Log .d (REACT_CLASS ,"onNewIntent " + intent );
218230 mActivity .setIntent (intent );
219231 mNewIntent = true ;
220232 reInitSession (mActivity );
@@ -227,6 +239,8 @@ public static void onNewIntent(@Nonnull Intent intent) {
227239 * @param uri the URI to include in the notification or null
228240 */
229241 private static void notifyJSOfInitSessionStart (Context context , Uri uri ) {
242+ Log .d (REACT_CLASS ,"notifyJSOfInitSessionStart " + uri );
243+
230244 /*
231245 * This check just ensures that we only generate one RNBranch.initSessionStart
232246 * event per call to onNewIntent().
@@ -239,15 +253,16 @@ private static void notifyJSOfInitSessionStart(Context context, Uri uri) {
239253 broadcastIntent .putExtra (NATIVE_INIT_SESSION_STARTED_EVENT_URI , uri );
240254 }
241255
256+ Log .d (REACT_CLASS , "Broadcasting NATIVE_INIT_SESSION_STARTED_EVENT" );
242257 LocalBroadcastManager .getInstance (context ).sendBroadcast (broadcastIntent );
243- Log .d (REACT_CLASS , "Sent session start broadcast for " + uri );
244258 }
245259
246260 /**
247261 * @deprecated setDebug is deprecated and all functionality has been disabled. If you wish to enable
248262 * logging, please invoke enableLogging. If you wish to simulate installs, please Test Devices
249263 * (https://help.branch.io/using-branch/docs/adding-test-devices)
250264 */
265+ @ Deprecated
251266 public static void setDebug () { }
252267
253268 public static void enableLogging () {
@@ -329,6 +344,7 @@ private void listenForInitSessionEventsToReactNative(ReactApplicationContext rea
329344 public void onReceive (Context context , Intent intent ) {
330345 final boolean hasError = (initSessionResult .has ("error" ) && !initSessionResult .isNull ("error" ));
331346 final String eventName = hasError ? RN_INIT_SESSION_ERROR_EVENT : RN_INIT_SESSION_SUCCESS_EVENT ;
347+
332348 mBranchModule .sendRNEvent (eventName , convertJsonToMap (initSessionResult ));
333349 }
334350
@@ -367,6 +383,8 @@ private BroadcastReceiver init(RNBranchModule branchModule) {
367383
368384 @ Override
369385 public void onCatalystInstanceDestroy () {
386+ Log .d (REACT_CLASS ,"onCatalystInstanceDestroy " );
387+
370388 LocalBroadcastManager .getInstance (getReactApplicationContext ()).unregisterReceiver (mInitSessionFinishedEventReceiver );
371389 LocalBroadcastManager .getInstance (getReactApplicationContext ()).unregisterReceiver (mInitSessionStartedEventReceiver );
372390 }
@@ -376,6 +394,12 @@ public String getName() {
376394 return NAME ;
377395 }
378396
397+ @ ReactMethod
398+ public void notifyNativeToInit (){
399+ Log .d (REACT_CLASS , "notifyNativeToInit" );
400+ Branch .notifyNativeToInit ();
401+ }
402+
379403 @ ReactMethod
380404 public void disableTracking (boolean disable ) {
381405 Branch branch = Branch .getInstance ();
@@ -681,6 +705,7 @@ public void onLinkCreate(String url, BranchError error) {
681705
682706 @ ReactMethod
683707 public void openURL (String url , ReadableMap options ) {
708+ Log .d (REACT_CLASS , "openURL url: " + url );
684709 if (mActivity == null ) {
685710 // initSession is called before JS loads. This probably indicates failure to call initSession
686711 // in an activity.
@@ -831,7 +856,7 @@ public static LinkProperties createLinkProperties(ReadableMap linkPropertiesMap,
831856 }
832857
833858 private static Branch setupBranch (Context context ) {
834- Branch branch = Branch .getInstance (context );
859+ Branch branch = Branch .getAutoInstance (context );
835860
836861 if (!mInitialized ) {
837862 Log .i (REACT_CLASS , "Initializing Branch SDK v. " + BuildConfig .VERSION_NAME );
0 commit comments