Skip to content

Commit ffecaed

Browse files
Remove methods that no longer exist in native SDKs (#726)
* Fixed deprecated methods * Update package.json * Removed deprecated methods * Update package.json
1 parent 0ff8e75 commit ffecaed

File tree

5 files changed

+22
-179
lines changed

5 files changed

+22
-179
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
6.0.0 Dec 1, 2023
22
* Update Android SDK to 5.7.5
33
* Update iOS SDK to 3.0.1
4+
* Updated iOS imports to work with the latest Branch SDK
5+
* Removed deprecated methods for CPID, BranchViewHandler, setCookieBasedMatching, and delayInitToCheckForSearchAds
46

57
5.2.1 Jan 4, 2023
68
* Fix Javascript method setLogging to enable logging in the native layer.

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SOFTWARE.
2424
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2525
xmlns:android="http://schemas.android.com/apk/res/android"
2626
id="branch-cordova-sdk"
27-
version="5.2.1">
27+
version="6.0.0">
2828

2929
<!-- Description -->
3030
<name>branch-cordova-sdk</name>

src/android/io/branch/BranchSDK.java

Lines changed: 11 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@
2222
import io.branch.indexing.BranchUniversalObject;
2323
import io.branch.referral.Branch;
2424
import io.branch.referral.BranchError;
25-
import io.branch.referral.BranchViewHandler;
26-
import io.branch.referral.ServerRequestGetCPID.BranchCrossPlatformIdListener;
2725
import io.branch.referral.ServerRequestGetLATD.BranchLastAttributedTouchDataListener;
2826
import io.branch.referral.SharingHelper;
2927
import io.branch.referral.QRCode.BranchQRCode;
3028
import io.branch.referral.util.BRANCH_STANDARD_EVENT;
31-
import io.branch.referral.util.BranchCPID;
3229
import io.branch.referral.util.BranchEvent;
3330
import io.branch.referral.util.ContentMetadata;
3431
import 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"))) {

src/ios/BranchSDK.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
#ifdef BRANCH_NPM
44
#import "Branch.h"
5+
#import "BranchEvent.h"
6+
#import "BranchQRCode.h"
57
#import "BranchLinkProperties.h"
68
#import "BranchUniversalObject.h"
79
#else
810
#import <BranchSDK/Branch.h>
11+
#import <BranchSDK/BranchEvent.h>
12+
#import <BranchSDK/BranchQRCode.h>
913
#import <BranchSDK/BranchLinkProperties.h>
1014
#import <BranchSDK/BranchUniversalObject.h>
1115
#endif
@@ -36,7 +40,6 @@
3640
- (void)setIdentity:(CDVInvokedUrlCommand*)command;
3741
- (void)registerDeepLinkController:(CDVInvokedUrlCommand*)command;
3842
- (void)logout:(CDVInvokedUrlCommand*)command;
39-
- (void)delayInitToCheckForSearchAds:(CDVInvokedUrlCommand*)command;
4043

4144
// Branch Universal Object Methods
4245
- (void)createBranchUniversalObject:(CDVInvokedUrlCommand*)command;
@@ -48,7 +51,6 @@
4851
- (void)listOnSpotlight:(CDVInvokedUrlCommand*)command;
4952

5053
// Branch Query Methods
51-
- (void)crossPlatformIds:(CDVInvokedUrlCommand *)command;
5254
- (void)lastAttributedTouchData:(CDVInvokedUrlCommand *)command;
5355

5456
@end

0 commit comments

Comments
 (0)