55import android .content .Intent ;
66import android .content .IntentFilter ;
77import android .content .BroadcastReceiver ;
8- import android .graphics .Bitmap ;
98import android .net .Uri ;
109import android .util .Base64 ;
1110
@@ -178,7 +177,7 @@ private void generateLocalBroadcast(JSONObject referringParams,
178177 BranchUniversalObject branchUniversalObject ,
179178 LinkProperties linkProperties ,
180179 BranchError error ) {
181-
180+
182181 Intent broadcastIntent = new Intent (NATIVE_INIT_SESSION_FINISHED_EVENT );
183182
184183 if (referringParams != null ) {
@@ -210,7 +209,7 @@ private void generateLocalBroadcast(JSONObject referringParams,
210209 }.init (reactActivity );
211210
212211 notifyJSOfInitSessionStart (reactActivity , uri );
213-
212+
214213 Branch .InitSessionBuilder initSessionBuilder = Branch .sessionBuilder (reactActivity ).withCallback (referralInitListener ).withData (uri );
215214 Log .d (REACT_CLASS , "sessionBuilder " + initSessionBuilder );
216215 initSessionBuilder .init ();
@@ -261,6 +260,10 @@ public static void enableLogging() {
261260 Branch .enableLogging ();
262261 }
263262
263+ public static void enableLogging (BranchLogger .BranchLogLevel logLevel ) {
264+ Branch .enableLogging (logLevel );
265+ }
266+
264267 public static void setRequestMetadata (String key , String val ) {
265268 if (key == null ) {
266269 return ;
@@ -336,7 +339,7 @@ private void listenForInitSessionEventsToReactNative(ReactApplicationContext rea
336339 public void onReceive (Context context , Intent intent ) {
337340 final boolean hasError = (initSessionResult .has ("error" ) && !initSessionResult .isNull ("error" ));
338341 final String eventName = hasError ? RN_INIT_SESSION_ERROR_EVENT : RN_INIT_SESSION_SUCCESS_EVENT ;
339-
342+
340343 mBranchModule .sendRNEvent (eventName , convertJsonToMap (initSessionResult ));
341344 }
342345
@@ -374,8 +377,8 @@ private BroadcastReceiver init(RNBranchModule branchModule) {
374377 }
375378
376379 @ Override
377- public void onCatalystInstanceDestroy () {
378- Log .d (REACT_CLASS ,"onCatalystInstanceDestroy " );
380+ public void invalidate () {
381+ Log .d (REACT_CLASS ,"React instance invalidate() " );
379382
380383 LocalBroadcastManager .getInstance (getReactApplicationContext ()).unregisterReceiver (mInitSessionFinishedEventReceiver );
381384 LocalBroadcastManager .getInstance (getReactApplicationContext ()).unregisterReceiver (mInitSessionStartedEventReceiver );
@@ -444,15 +447,15 @@ public void getFirstReferringParams(Promise promise) {
444447 public void lastAttributedTouchData (int window , final Promise promise ) {
445448 Branch branch = Branch .getInstance ();
446449 branch .getLastAttributedTouchData (new ServerRequestGetLATD .BranchLastAttributedTouchDataListener () {
447- @ Override
448- public void onDataFetched (JSONObject jsonObject , BranchError error ) {
449- if (error == null ) {
450- promise .resolve (convertJsonToMap (jsonObject ));
451- } else {
452- promise .reject (GENERIC_ERROR , error .getMessage ());
453- }
450+ @ Override
451+ public void onDataFetched (JSONObject jsonObject , BranchError error ) {
452+ if (error == null ) {
453+ promise .resolve (convertJsonToMap (jsonObject ));
454+ } else {
455+ promise .reject (GENERIC_ERROR , error .getMessage ());
454456 }
455- }, window );
457+ }
458+ }, window );
456459 }
457460
458461 @ ReactMethod
@@ -461,7 +464,7 @@ public void setIdentity(String identity) {
461464 branch .setIdentity (identity );
462465 }
463466
464- @ ReactMethod
467+ @ ReactMethod
465468 public void setIdentityAsync (String identity , final Promise promise ) {
466469 Branch branch = Branch .getInstance ();
467470 branch .setIdentity (identity , new Branch .BranchReferralInitListener () {
@@ -633,7 +636,7 @@ private Branch.BranchLinkShareListener init(Promise promise) {
633636 public void registerView (String ident , Promise promise ) {
634637 BranchUniversalObject branchUniversalObject = findUniversalObjectOrReject (ident , promise );
635638 if (branchUniversalObject == null ) {
636- return ;
639+ return ;
637640 }
638641
639642 branchUniversalObject .registerView ();
@@ -692,9 +695,9 @@ public void openURL(String url, ReadableMap options) {
692695 mActivity .startActivity (intent );
693696 }
694697
695- @ ReactMethod
698+ @ ReactMethod
696699 public void getBranchQRCode (ReadableMap branchQRCodeSettingsMap , ReadableMap branchUniversalObjectMap , ReadableMap linkPropertiesMap , ReadableMap controlParamsMap , final Promise promise ) {
697-
700+
698701 BranchUniversalObject branchUniversalObject = createBranchUniversalObject (branchUniversalObjectMap );
699702 LinkProperties linkProperties = createLinkProperties (linkPropertiesMap , controlParamsMap );
700703 BranchQRCode qrCode = createBranchQRCode (branchQRCodeSettingsMap );
@@ -706,13 +709,13 @@ public void onSuccess(byte[] qrCodeData) {
706709 String qrCodeString = Base64 .encodeToString (qrCodeData , Base64 .DEFAULT );
707710 promise .resolve (qrCodeString );
708711 }
709-
712+
710713 @ Override
711714 public void onFailure (Exception e ) {
712715 Log .d ("Failed to get QR Code" , e .getMessage ());
713716 promise .reject ("Failed to get QR Code" , e .getMessage ());
714- }
715- });
717+ }
718+ });
716719 } catch (IOException e ) {
717720 e .printStackTrace ();
718721 Log .d ("Failed to get QR Code" , e .getMessage ());
@@ -728,7 +731,7 @@ public BranchQRCode createBranchQRCode(ReadableMap branchQRCodeSettingsMap) {
728731 if (branchQRCodeSettingsMap .hasKey ("centerLogo" )) branchQRCode .setCenterLogo (branchQRCodeSettingsMap .getString ("centerLogo" ));
729732 if (branchQRCodeSettingsMap .hasKey ("width" )) branchQRCode .setWidth (branchQRCodeSettingsMap .getInt ("width" ));
730733 if (branchQRCodeSettingsMap .hasKey ("margin" )) branchQRCode .setMargin (branchQRCodeSettingsMap .getInt ("margin" ));
731-
734+
732735 if (branchQRCodeSettingsMap .hasKey ("imageFormat" )) {
733736 String imageFormat = branchQRCodeSettingsMap .getString ("imageFormat" );
734737 if (imageFormat != null ) {
@@ -780,7 +783,7 @@ public static BranchEvent createBranchEvent(String eventName, ReadableMap params
780783 ReadableMapKeySetIterator it = customData .keySetIterator ();
781784 while (it .hasNextKey ()) {
782785 String key = it .nextKey ();
783-
786+
784787 ReadableType readableType = customData .getType (key );
785788 if (readableType == ReadableType .String ) {
786789 event .addCustomDataProperty (key , customData .getString (key ));
@@ -1085,9 +1088,9 @@ private Runnable init(ReactApplicationContext _context, Handler _mainHandler, St
10851088 @ Override
10861089 public void run () {
10871090 try {
1088- Log .d (REACT_CLASS , "Catalyst instance poller try " + Integer .toString (tries ));
1089- if (mContext .hasActiveCatalystInstance ()) {
1090- Log .d (REACT_CLASS , "Catalyst instance active " );
1091+ Log .d (REACT_CLASS , "React instance poller try " + Integer .toString (tries ));
1092+ if (mContext .hasActiveReactInstance ()) {
1093+ Log .d (REACT_CLASS , "Has React instance " );
10911094 mContext
10921095 .getJSModule (DeviceEventManagerModule .RCTDeviceEventEmitter .class )
10931096 .emit (mEventName , mParams );
@@ -1096,12 +1099,12 @@ public void run() {
10961099 if (tries <= maxTries ) {
10971100 mMainHandler .postDelayed (this , pollDelayInMs );
10981101 } else {
1099- Log .e (REACT_CLASS , "Could not get Catalyst instance" );
1102+ Log .e (REACT_CLASS , "Could not get React instance" );
11001103 }
11011104 }
11021105 }
11031106 catch (Exception e ) {
1104- e . printStackTrace ( );
1107+ Log . e ( REACT_CLASS , Objects . requireNonNull ( e . getMessage ()) );
11051108 }
11061109 }
11071110 }.init (context , mainHandler , eventName , params );
0 commit comments