22
22
import io .branch .indexing .BranchUniversalObject ;
23
23
import io .branch .referral .Branch ;
24
24
import io .branch .referral .BranchError ;
25
- import io .branch .referral .BranchViewHandler ;
26
- import io .branch .referral .ServerRequestGetCPID .BranchCrossPlatformIdListener ;
27
25
import io .branch .referral .ServerRequestGetLATD .BranchLastAttributedTouchDataListener ;
28
26
import io .branch .referral .SharingHelper ;
29
27
import io .branch .referral .QRCode .BranchQRCode ;
30
28
import io .branch .referral .util .BRANCH_STANDARD_EVENT ;
31
- import io .branch .referral .util .BranchCPID ;
32
29
import io .branch .referral .util .BranchEvent ;
33
30
import io .branch .referral .util .ContentMetadata ;
34
31
import io .branch .referral .util .CurrencyType ;
@@ -42,7 +39,6 @@ static class BranchLinkProperties extends io.branch.referral.util.LinkProperties
42
39
43
40
// Standard Debugging Variables
44
41
private static final String LCAT = "CordovaBranchSDK" ;
45
-
46
42
private static final String BRANCH_PLUGIN_TYPE = "CordovaIonic" ;
47
43
private static final String BRANCH_PLUGIN_VERSION = "%BRANCH_PLUGIN_VERSION%" ;
48
44
@@ -85,23 +81,6 @@ public void onNewIntent(Intent intent) {
85
81
this .activity .setIntent (intent );
86
82
}
87
83
88
- /**
89
- * Handle depreciated call to sendJavaScript for more recent method
90
- */
91
- @ TargetApi (Build .VERSION_CODES .KITKAT )
92
- private void sendJavascript (final String javascript ) {
93
- webView .getView ().post (new Runnable () {
94
- @ Override
95
- public void run () {
96
- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT ) {
97
- webView .sendJavascript (javascript );
98
- } else {
99
- webView .loadUrl ("javascript:" + javascript );
100
- }
101
- }
102
- });
103
- }
104
-
105
84
/**
106
85
* <p>
107
86
* cordova.exec() method reference.
@@ -122,9 +101,6 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
122
101
if (action .equals ("enableLogging" )) {
123
102
cordova .getActivity ().runOnUiThread (r );
124
103
return true ;
125
- } else if (action .equals ("setCookieBasedMatching" )) {
126
- cordova .getActivity ().runOnUiThread (r );
127
- return true ;
128
104
} else if (action .equals ("disableTracking" )) {
129
105
cordova .getActivity ().runOnUiThread (r );
130
106
return true ;
@@ -141,7 +117,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
141
117
return true ;
142
118
} else if (action .equals ("sendBranchEvent" )) {
143
119
if (args .length () < 1 && args .length () > 2 ) {
144
- callbackContext .error (String . format ( "Parameter count mismatch" ) );
120
+ callbackContext .error ("Parameter count mismatch" );
145
121
return false ;
146
122
}
147
123
cordova .getActivity ().runOnUiThread (r );
@@ -157,37 +133,33 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
157
133
return true ;
158
134
} else if (action .equals ("createBranchUniversalObject" )) {
159
135
if (args .length () != 1 ) {
160
- callbackContext .error (String . format ( "Parameter count mismatch" ) );
136
+ callbackContext .error ("Parameter count mismatch" );
161
137
return false ;
162
138
}
163
139
cordova .getActivity ().runOnUiThread (r );
164
140
return true ;
165
141
166
- } else if (action .equals ("crossPlatformIds" )) {
167
- cordova .getActivity ().runOnUiThread (r );
168
- return true ;
169
-
170
142
} else if (action .equals ("lastAttributedTouchData" )) {
171
143
cordova .getActivity ().runOnUiThread (r );
172
- return true ;
144
+ return true ;
173
145
174
146
} else if (action .equals (("generateShortUrl" ))) {
175
147
if (args .length () != 3 ) {
176
- callbackContext .error (String . format ( "Parameter count mismatch" ) );
148
+ callbackContext .error ("Parameter count mismatch" );
177
149
return false ;
178
150
}
179
151
cordova .getActivity ().runOnUiThread (r );
180
152
return true ;
181
153
} else if (action .equals ("registerView" )) {
182
154
if (args .length () != 1 ) {
183
- callbackContext .error (String . format ( "Parameter count mismatch" ) );
155
+ callbackContext .error ("Parameter count mismatch" );
184
156
return false ;
185
157
}
186
158
cordova .getActivity ().runOnUiThread (r );
187
159
return true ;
188
160
} else if (action .equals ("showShareSheet" )) {
189
161
if (args .length () < 3 ) {
190
- callbackContext .error (String . format ( "Parameter count mismatch" ) );
162
+ callbackContext .error ("Parameter count mismatch" );
191
163
return false ;
192
164
}
193
165
cordova .getActivity ().runOnUiThread (r );
@@ -222,11 +194,11 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
222
194
223
195
} else if (action .equals ("getBranchQRCode" )) {
224
196
if (args .length () != 4 ) {
225
- callbackContext .error (String . format ( "Parameter count mismatch" ) );
197
+ callbackContext .error ("Parameter count mismatch" );
226
198
return false ;
227
199
}
228
200
cordova .getActivity ().runOnUiThread (r );
229
- return true ;
201
+ return true ;
230
202
}
231
203
232
204
return true ;
@@ -239,10 +211,6 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
239
211
return false ;
240
212
241
213
}
242
-
243
- public void crossPlatformIds (CallbackContext callbackContext ) {
244
- this .instance .getCrossPlatformIds (new BranchCPIDListener (callbackContext ));
245
- }
246
214
247
215
public void lastAttributedTouchData (CallbackContext callbackContext ) {
248
216
this .instance .getLastAttributedTouchData (new BranchLATDListener (callbackContext ), 30 );
@@ -268,7 +236,7 @@ private void initSession(CallbackContext callbackContext) {
268
236
this .deepLinkUrl = data .toString ();
269
237
}
270
238
271
- this . instance . initSession ( new SessionListener (callbackContext ), data , activity );
239
+ Branch . sessionBuilder ( activity ). withData ( data ). withCallback ( new SessionListener (callbackContext )). init ( );
272
240
}
273
241
274
242
/**
@@ -576,24 +544,6 @@ public void onFailure(Exception e) {
576
544
}
577
545
}
578
546
579
- /**
580
- * <p>Sets the cookie based matching for all incoming requests.</p>
581
- * <p>If you want cookie based matching, call this <b>before</b> initUserSession</p>
582
- *
583
- * @param linkDomain A {@link String} value to of the link domain for cookie based matching.
584
- * @param callbackContext A callback to execute at the end of this method
585
- */
586
- private void setCookieBasedMatching (String linkDomain , CallbackContext callbackContext ) {
587
-
588
- this .activity = this .cordova .getActivity ();
589
-
590
- if (linkDomain != null ) {
591
- Branch .enableCookieBasedMatching (linkDomain );
592
- }
593
-
594
- callbackContext .success ("Success" );
595
- }
596
-
597
547
/**
598
548
* <p>Enabling Branch SDK logging</p>
599
549
*
@@ -642,7 +592,8 @@ private void setIdentity(String newIdentity, CallbackContext callbackContext) {
642
592
/**
643
593
* <p>Allow Branch SDK to pass the user's Mixpanel distinct id to our servers. Branch will then pass that Distinct ID to Mixpanel when logging any event.</p>
644
594
*
645
- * @param token A {@link String} value containing the unique identifier of the Mixpanel user.
595
+ * @param key A {@link String} value containing the key for the unique identifier of the Mixpanel user.
596
+ * @param val A {@link String} value containing the value for the unique identifier of the Mixpanel user.
646
597
* @param callbackContext A callback to execute at the end of this method
647
598
*/
648
599
private void setRequestMetadata (String key , String val , CallbackContext callbackContext ) {
@@ -800,39 +751,6 @@ public BranchUniversalObjectWrapper(BranchUniversalObject branchUniversalObj) {
800
751
//----------- INNER CLASS LISTENERS ------------//
801
752
//////////////////////////////////////////////////
802
753
803
- protected class BranchCPIDListener implements BranchCrossPlatformIdListener {
804
- private CallbackContext _callbackContext ;
805
-
806
- public BranchCPIDListener (CallbackContext callbackContext ) {
807
- this ._callbackContext = callbackContext ;
808
- }
809
-
810
- @ Override
811
- public void onDataFetched (BranchCPID branchCPID , BranchError error ) {
812
- if (error != null ) {
813
- Log .d (LCAT , "CPID unavailable" );
814
- this ._callbackContext .error ("CPID unavailable" );
815
- } else {
816
-
817
- JSONObject jsonObject = new JSONObject ();
818
- try {
819
- jsonObject .put ("developer_identity" , branchCPID .getDeveloperIdentity ());
820
- jsonObject .put ("cross_platform_id" , branchCPID .getCrossPlatformID ());
821
- jsonObject .put ("past_cross_platform_ids" , branchCPID .getPastCrossPlatformIds ());
822
- jsonObject .put ("prob_cross_platform_ids" , branchCPID .getProbabilisticCrossPlatformIds ());
823
- } catch (JSONException e ) {
824
- // just send back and empty object on json error
825
- jsonObject = new JSONObject ();
826
- }
827
-
828
- Log .d (LCAT , jsonObject .toString ());
829
-
830
- PluginResult result = new PluginResult (PluginResult .Status .OK , jsonObject );
831
- this ._callbackContext .sendPluginResult (result );
832
- }
833
- }
834
- }
835
-
836
754
protected class BranchLATDListener implements BranchLastAttributedTouchDataListener {
837
755
private CallbackContext _callbackContext ;
838
756
@@ -854,35 +772,6 @@ public void onDataFetched(JSONObject jsonObject, BranchError error) {
854
772
}
855
773
}
856
774
857
- protected class BranchViewEventsListener implements BranchViewHandler .IBranchViewEvents {
858
-
859
- private CallbackContext _callbackContext ;
860
-
861
- public BranchViewEventsListener (CallbackContext callbackContext ) {
862
- callbackContext .success ("Success" );
863
- }
864
-
865
- @ Override
866
- public void onBranchViewVisible (String action , String branchViewID ) {
867
-
868
- }
869
-
870
- @ Override
871
- public void onBranchViewAccepted (String action , String branchViewID ) {
872
-
873
- }
874
-
875
- @ Override
876
- public void onBranchViewCancelled (String action , String branchViewID ) {
877
-
878
- }
879
-
880
- @ Override
881
- public void onBranchViewError (int errorCode , String errorMsg , String action ) {
882
-
883
- }
884
- }
885
-
886
775
protected class SessionListener implements Branch .BranchReferralInitListener {
887
776
private CallbackContext _callbackContext ;
888
777
@@ -1194,8 +1083,6 @@ public void run() {
1194
1083
1195
1084
if (this .action .equals ("enableLogging" )) {
1196
1085
enableLogging (this .args .getBoolean (0 ), this .callbackContext );
1197
- } else if (this .action .equals ("setCookieBasedMatching" )) {
1198
- setCookieBasedMatching (this .args .getString (0 ), this .callbackContext );
1199
1086
} else if (this .action .equals ("disableTracking" )) {
1200
1087
disableTracking (this .args .getBoolean (0 ), this .callbackContext );
1201
1088
} else if (this .action .equals ("initSession" )) {
@@ -1219,8 +1106,6 @@ public void run() {
1219
1106
logout (this .callbackContext );
1220
1107
} else if (this .action .equals ("createBranchUniversalObject" )) {
1221
1108
createBranchUniversalObject (this .args .getJSONObject (0 ), this .callbackContext );
1222
- } else if (this .action .equals ("crossPlatformIds" )) {
1223
- crossPlatformIds (this .callbackContext );
1224
1109
} else if (this .action .equals ("lastAttributedTouchData" )) {
1225
1110
lastAttributedTouchData (this .callbackContext );
1226
1111
} else if (this .action .equals (("generateShortUrl" ))) {
0 commit comments