20
20
21
21
import io .branch .indexing .BranchUniversalObject ;
22
22
import io .branch .referral .Branch ;
23
+ import io .branch .referral .BranchUtil ;
24
+ import io .branch .referral .PrefHelper ;
23
25
import io .branch .referral .BranchError ;
24
26
import io .branch .referral .BranchViewHandler ;
25
27
import io .branch .referral .SharingHelper ;
31
33
import io .branch .referral .util .ProductCategory ;
32
34
import io .branch .referral .util .ShareSheetStyle ;
33
35
34
- import io .branch .referral .util .BranchCrossPlatformId ;
35
- import io .branch .referral .util .BranchLastAttributedTouchData ;
36
+ import io .branch .referral .ServerRequestGetLATD .BranchLastAttributedTouchDataListener ;
37
+ import io .branch .referral .ServerRequestGetCPID .BranchCrossPlatformIdListener ;
38
+ import io .branch .referral .util .BranchCPID ;
36
39
37
40
public class BranchSDK extends CordovaPlugin {
38
41
@@ -68,17 +71,18 @@ public BranchSDK() {
68
71
protected void pluginInitialize () {
69
72
70
73
this .activity = this .cordova .getActivity ();
71
-
72
74
Branch .disableInstantDeepLinking (true );
73
- Branch .getAutoInstance (this .activity .getApplicationContext ());
74
-
75
+ BranchUtil .setPluginType (BranchUtil .PluginType .CordovaIonic );
76
+ if (this .instance == null ) {
77
+ this .instance = Branch .getAutoInstance (this .activity .getApplicationContext ());
78
+ }
75
79
}
76
80
77
81
/**
78
82
* Called when the activity receives a new intent.
79
83
*/
80
84
public void onNewIntent (Intent intent ) {
81
-
85
+ intent . putExtra ( "branch_force_new_session" , true );
82
86
this .activity .setIntent (intent );
83
87
84
88
this .reInitSession ();
@@ -292,7 +296,6 @@ private void initSession(CallbackContext callbackContext) {
292
296
}
293
297
294
298
this .sessionListener = new SessionListener (callbackContext );
295
- this .instance = Branch .getAutoInstance (this .activity .getApplicationContext ());
296
299
this .instance .initSession (this .sessionListener , data , activity );
297
300
}
298
301
@@ -613,10 +616,8 @@ private void setCookieBasedMatching(String linkDomain, CallbackContext callbackC
613
616
614
617
this .activity = this .cordova .getActivity ();
615
618
616
- Branch instance = Branch .getAutoInstance (this .activity .getApplicationContext ());
617
-
618
619
if (linkDomain != null ) {
619
- instance .enableCookieBasedMatching (linkDomain );
620
+ Branch .enableCookieBasedMatching (linkDomain );
620
621
}
621
622
622
623
callbackContext .success ("Success" );
@@ -631,7 +632,7 @@ private void setCookieBasedMatching(String linkDomain, CallbackContext callbackC
631
632
*/
632
633
private void setDebug (boolean isEnable , CallbackContext callbackContext ) {
633
634
this .activity = this .cordova .getActivity ();
634
- Branch .getAutoInstance ( this . activity . getApplicationContext ()). setDebug ();
635
+ Branch .enableDebugMode ();
635
636
callbackContext .sendPluginResult (new PluginResult (PluginResult .Status .OK , isEnable ));
636
637
}
637
638
@@ -645,7 +646,8 @@ private void setDebug(boolean isEnable, CallbackContext callbackContext) {
645
646
*/
646
647
private void disableTracking (boolean isEnable , CallbackContext callbackContext ) {
647
648
this .activity = this .cordova .getActivity ();
648
- Branch .getAutoInstance (this .activity .getApplicationContext ()).disableTracking (isEnable );
649
+
650
+ this .instance .disableTracking (isEnable );
649
651
callbackContext .sendPluginResult (new PluginResult (PluginResult .Status .OK , isEnable ));
650
652
}
651
653
@@ -892,15 +894,15 @@ public BranchUniversalObjectWrapper(BranchUniversalObject branchUniversalObj) {
892
894
//----------- INNER CLASS LISTENERS ------------//
893
895
//////////////////////////////////////////////////
894
896
895
- protected class BranchCPIDListener implements BranchCrossPlatformId . BranchCrossPlatformIdListener {
897
+ protected class BranchCPIDListener implements BranchCrossPlatformIdListener {
896
898
private CallbackContext _callbackContext ;
897
899
898
900
public BranchCPIDListener (CallbackContext callbackContext ) {
899
901
this ._callbackContext = callbackContext ;
900
902
}
901
903
902
904
@ Override
903
- public void onDataFetched (BranchCrossPlatformId . BranchCPID branchCPID , BranchError error ) {
905
+ public void onDataFetched (BranchCPID branchCPID , BranchError error ) {
904
906
if (error != null ) {
905
907
Log .d (LCAT , "CPID unavailable" );
906
908
this ._callbackContext .error ("CPID unavailable" );
@@ -925,7 +927,7 @@ public void onDataFetched(BranchCrossPlatformId.BranchCPID branchCPID, BranchErr
925
927
}
926
928
}
927
929
928
- protected class BranchLATDListener implements BranchLastAttributedTouchData . BranchLastAttributedTouchDataListener {
930
+ protected class BranchLATDListener implements BranchLastAttributedTouchDataListener {
929
931
private CallbackContext _callbackContext ;
930
932
931
933
public BranchLATDListener (CallbackContext callbackContext ) {
0 commit comments