2222import io .branch .indexing .BranchUniversalObject ;
2323import io .branch .referral .Branch ;
2424import io .branch .referral .BranchError ;
25- import io .branch .referral .BranchViewHandler ;
26- import io .branch .referral .ServerRequestGetCPID .BranchCrossPlatformIdListener ;
2725import io .branch .referral .ServerRequestGetLATD .BranchLastAttributedTouchDataListener ;
2826import io .branch .referral .SharingHelper ;
2927import io .branch .referral .QRCode .BranchQRCode ;
3028import io .branch .referral .util .BRANCH_STANDARD_EVENT ;
31- import io .branch .referral .util .BranchCPID ;
3229import io .branch .referral .util .BranchEvent ;
3330import io .branch .referral .util .ContentMetadata ;
3431import io .branch .referral .util .CurrencyType ;
@@ -42,7 +39,6 @@ static class BranchLinkProperties extends io.branch.referral.util.LinkProperties
4239
4340 // Standard Debugging Variables
4441 private static final String LCAT = "CordovaBranchSDK" ;
45-
4642 private static final String BRANCH_PLUGIN_TYPE = "CordovaIonic" ;
4743 private static final String BRANCH_PLUGIN_VERSION = "%BRANCH_PLUGIN_VERSION%" ;
4844
@@ -85,23 +81,6 @@ public void onNewIntent(Intent intent) {
8581 this .activity .setIntent (intent );
8682 }
8783
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-
10584 /**
10685 * <p>
10786 * cordova.exec() method reference.
@@ -122,9 +101,6 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
122101 if (action .equals ("enableLogging" )) {
123102 cordova .getActivity ().runOnUiThread (r );
124103 return true ;
125- } else if (action .equals ("setCookieBasedMatching" )) {
126- cordova .getActivity ().runOnUiThread (r );
127- return true ;
128104 } else if (action .equals ("disableTracking" )) {
129105 cordova .getActivity ().runOnUiThread (r );
130106 return true ;
@@ -141,7 +117,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
141117 return true ;
142118 } else if (action .equals ("sendBranchEvent" )) {
143119 if (args .length () < 1 && args .length () > 2 ) {
144- callbackContext .error (String . format ( "Parameter count mismatch" ) );
120+ callbackContext .error ("Parameter count mismatch" );
145121 return false ;
146122 }
147123 cordova .getActivity ().runOnUiThread (r );
@@ -157,37 +133,33 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
157133 return true ;
158134 } else if (action .equals ("createBranchUniversalObject" )) {
159135 if (args .length () != 1 ) {
160- callbackContext .error (String . format ( "Parameter count mismatch" ) );
136+ callbackContext .error ("Parameter count mismatch" );
161137 return false ;
162138 }
163139 cordova .getActivity ().runOnUiThread (r );
164140 return true ;
165141
166- } else if (action .equals ("crossPlatformIds" )) {
167- cordova .getActivity ().runOnUiThread (r );
168- return true ;
169-
170142 } else if (action .equals ("lastAttributedTouchData" )) {
171143 cordova .getActivity ().runOnUiThread (r );
172- return true ;
144+ return true ;
173145
174146 } else if (action .equals (("generateShortUrl" ))) {
175147 if (args .length () != 3 ) {
176- callbackContext .error (String . format ( "Parameter count mismatch" ) );
148+ callbackContext .error ("Parameter count mismatch" );
177149 return false ;
178150 }
179151 cordova .getActivity ().runOnUiThread (r );
180152 return true ;
181153 } else if (action .equals ("registerView" )) {
182154 if (args .length () != 1 ) {
183- callbackContext .error (String . format ( "Parameter count mismatch" ) );
155+ callbackContext .error ("Parameter count mismatch" );
184156 return false ;
185157 }
186158 cordova .getActivity ().runOnUiThread (r );
187159 return true ;
188160 } else if (action .equals ("showShareSheet" )) {
189161 if (args .length () < 3 ) {
190- callbackContext .error (String . format ( "Parameter count mismatch" ) );
162+ callbackContext .error ("Parameter count mismatch" );
191163 return false ;
192164 }
193165 cordova .getActivity ().runOnUiThread (r );
@@ -222,11 +194,11 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
222194
223195 } else if (action .equals ("getBranchQRCode" )) {
224196 if (args .length () != 4 ) {
225- callbackContext .error (String . format ( "Parameter count mismatch" ) );
197+ callbackContext .error ("Parameter count mismatch" );
226198 return false ;
227199 }
228200 cordova .getActivity ().runOnUiThread (r );
229- return true ;
201+ return true ;
230202 }
231203
232204 return true ;
@@ -239,10 +211,6 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
239211 return false ;
240212
241213 }
242-
243- public void crossPlatformIds (CallbackContext callbackContext ) {
244- this .instance .getCrossPlatformIds (new BranchCPIDListener (callbackContext ));
245- }
246214
247215 public void lastAttributedTouchData (CallbackContext callbackContext ) {
248216 this .instance .getLastAttributedTouchData (new BranchLATDListener (callbackContext ), 30 );
@@ -268,7 +236,7 @@ private void initSession(CallbackContext callbackContext) {
268236 this .deepLinkUrl = data .toString ();
269237 }
270238
271- this . instance . initSession ( new SessionListener (callbackContext ), data , activity );
239+ Branch . sessionBuilder ( activity ). withData ( data ). withCallback ( new SessionListener (callbackContext )). init ( );
272240 }
273241
274242 /**
@@ -576,24 +544,6 @@ public void onFailure(Exception e) {
576544 }
577545 }
578546
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-
597547 /**
598548 * <p>Enabling Branch SDK logging</p>
599549 *
@@ -642,7 +592,8 @@ private void setIdentity(String newIdentity, CallbackContext callbackContext) {
642592 /**
643593 * <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>
644594 *
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.
646597 * @param callbackContext A callback to execute at the end of this method
647598 */
648599 private void setRequestMetadata (String key , String val , CallbackContext callbackContext ) {
@@ -800,39 +751,6 @@ public BranchUniversalObjectWrapper(BranchUniversalObject branchUniversalObj) {
800751 //----------- INNER CLASS LISTENERS ------------//
801752 //////////////////////////////////////////////////
802753
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-
836754 protected class BranchLATDListener implements BranchLastAttributedTouchDataListener {
837755 private CallbackContext _callbackContext ;
838756
@@ -854,35 +772,6 @@ public void onDataFetched(JSONObject jsonObject, BranchError error) {
854772 }
855773 }
856774
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-
886775 protected class SessionListener implements Branch .BranchReferralInitListener {
887776 private CallbackContext _callbackContext ;
888777
@@ -1194,8 +1083,6 @@ public void run() {
11941083
11951084 if (this .action .equals ("enableLogging" )) {
11961085 enableLogging (this .args .getBoolean (0 ), this .callbackContext );
1197- } else if (this .action .equals ("setCookieBasedMatching" )) {
1198- setCookieBasedMatching (this .args .getString (0 ), this .callbackContext );
11991086 } else if (this .action .equals ("disableTracking" )) {
12001087 disableTracking (this .args .getBoolean (0 ), this .callbackContext );
12011088 } else if (this .action .equals ("initSession" )) {
@@ -1219,8 +1106,6 @@ public void run() {
12191106 logout (this .callbackContext );
12201107 } else if (this .action .equals ("createBranchUniversalObject" )) {
12211108 createBranchUniversalObject (this .args .getJSONObject (0 ), this .callbackContext );
1222- } else if (this .action .equals ("crossPlatformIds" )) {
1223- crossPlatformIds (this .callbackContext );
12241109 } else if (this .action .equals ("lastAttributedTouchData" )) {
12251110 lastAttributedTouchData (this .callbackContext );
12261111 } else if (this .action .equals (("generateShortUrl" ))) {
0 commit comments