Skip to content

Commit d7e5bb6

Browse files
committed
Updated CPP
1 parent 59e1db0 commit d7e5bb6

File tree

7 files changed

+96
-5
lines changed

7 files changed

+96
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
6.5.0 Jan 14, 2025
2+
* Update Android SDK to 5.15.0
3+
* Update iOS SDK to 3.8.0
4+
* Added new method `setConsumerProtectionAttributionLevel` to set CPP level
5+
16
6.4.0 Nov 1, 2024
27
* Update Android SDK to 5.13.0
38
* Update iOS SDK to 3.6.5

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "branch-cordova-sdk",
33
"description": "Branch Metrics Cordova SDK",
44
"main": "src/index.js",
5-
"version": "6.4.0",
5+
"version": "6.5.0-alpha.0",
66
"homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking",
77
"repository": {
88
"type": "git",

plugin.xml

Lines changed: 3 additions & 3 deletions
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="6.4.0">
27+
version="6.5.0">
2828

2929
<!-- Description -->
3030
<name>branch-cordova-sdk</name>
@@ -63,7 +63,7 @@ SOFTWARE.
6363
<!-- Manifest configuration is done via a js script. We should move it to this config in the future. -->
6464

6565
<source-file src="src/android/io/branch/BranchSDK.java" target-dir="src/io/branch" />
66-
<framework src="io.branch.sdk.android:library:5.13.0"/>
66+
<framework src="io.branch.sdk.android:library:5.15.0"/>
6767
</platform>
6868

6969
<!-- iOS -->
@@ -88,7 +88,7 @@ SOFTWARE.
8888
<source url="https://cdn.cocoapods.org/"/>
8989
</config>
9090
<pods>
91-
<pod name="BranchSDK" spec="~> 3.6.5" />
91+
<pod name="BranchSDK" spec="~> 3.8.0" />
9292
</pods>
9393
</podspec>
9494
</platform>

src/android/io/branch/BranchSDK.java

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.branch.referral.util.ContentMetadata;
3131
import io.branch.referral.util.CurrencyType;
3232
import io.branch.referral.util.ShareSheetStyle;
33+
import io.branch.referral.BranchAttributionLevel;
3334

3435

3536
public class BranchSDK extends CordovaPlugin {
@@ -112,7 +113,14 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
112113
return true;
113114
} else {
114115
if (this.instance != null) {
115-
if (action.equals("setIdentity")) {
116+
if (action.equals("setConsumerProtectionAttributionLevel")) {
117+
if (args.length() != 1) {
118+
callbackContext.error("Parameter count mismatch");
119+
return false;
120+
}
121+
cordova.getActivity().runOnUiThread(r);
122+
return true;
123+
} else if (action.equals("setIdentity")) {
116124
cordova.getActivity().runOnUiThread(r);
117125
return true;
118126
} else if (action.equals("sendBranchEvent")) {
@@ -698,6 +706,44 @@ public void setDMAParamsForEEA(boolean eeaRegion, boolean adPersonalizationConse
698706
Branch.getInstance().setDMAParamsForEEA(eeaRegion, adPersonalizationConsent, adUserDataUsageConsent);
699707
}
700708

709+
/**
710+
* <p>Sets the CPP level.</p>
711+
*
712+
* @param level A {@link String} value indicating the desired attribution level. Valid values are:
713+
* "FULL" - Full attribution with all data collection enabled
714+
* "REDUCED" - Reduced attribution with limited data collection
715+
* "MINIMAL" - Minimal attribution with very limited data collection
716+
* "NONE" - No attribution or data collection
717+
* @param callbackContext A callback to execute at the end of this method
718+
*/
719+
720+
private void setConsumerProtectionAttributionLevel(String level, CallbackContext callbackContext) {
721+
Branch branch = Branch.getInstance();
722+
BranchAttributionLevel attributionLevel;
723+
724+
switch (level) {
725+
case "FULL":
726+
attributionLevel = BranchAttributionLevel.FULL;
727+
break;
728+
case "REDUCED":
729+
attributionLevel = BranchAttributionLevel.REDUCED;
730+
break;
731+
case "MINIMAL":
732+
attributionLevel = BranchAttributionLevel.MINIMAL;
733+
break;
734+
case "NONE":
735+
attributionLevel = BranchAttributionLevel.NONE;
736+
break;
737+
default:
738+
Log.w(LCAT, "Invalid attribution level: " + level);
739+
callbackContext.error("Invalid attribution level: " + level);
740+
return;
741+
}
742+
743+
branch.setConsumerProtectionAttributionLevel(attributionLevel);
744+
callbackContext.success("Success");
745+
}
746+
701747
private BranchUniversalObject getContentItem(JSONObject item) throws JSONException {
702748
BranchUniversalObject universalObject = new BranchUniversalObject();
703749
ContentMetadata contentMetadata = new ContentMetadata();
@@ -1149,11 +1195,15 @@ public void run() {
11491195
showShareSheet(this.args.getInt(0), this.args.getJSONObject(1), this.args.getJSONObject(2), localization);
11501196
} else if (this.action.equals("setDMAParamsForEEA")) {
11511197
setDMAParamsForEEA(this.args.getBoolean(0), this.args.getBoolean(1), this.args.getBoolean(2));
1198+
} else if (this.action.equals("setConsumerProtectionAttributionLevel")) {
1199+
setConsumerProtectionAttributionLevel(this.args.getString(0), this.callbackContext);
11521200
}
11531201
}
11541202
} catch (JSONException e) {
11551203
e.printStackTrace();
11561204
}
11571205
}
11581206
}
1207+
1208+
11591209
}

src/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,5 +322,13 @@ const validateParam = (param, paramName) => {
322322
}
323323
};
324324

325+
Branch.prototype.setConsumerProtectionAttributionLevel =
326+
function setConsumerProtectionAttributionLevel(level) {
327+
if (typeof level !== "string") {
328+
return executeReject("Attribution level must be a string");
329+
}
330+
return execute("setConsumerProtectionAttributionLevel", [level]);
331+
};
332+
325333
// export Branch object
326334
module.exports = new Branch();

src/ios/BranchSDK.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
- (void)registerDeepLinkController:(CDVInvokedUrlCommand*)command;
4242
- (void)logout:(CDVInvokedUrlCommand*)command;
4343
- (void)setDMAParamsForEEA:(CDVInvokedUrlCommand*)command;
44+
- (void)setConsumerProtectionAttributionLevel:(CDVInvokedUrlCommand*)command;
4445

4546
// Branch Universal Object Methods
4647
- (void)createBranchUniversalObject:(CDVInvokedUrlCommand*)command;
@@ -54,4 +55,5 @@
5455
// Branch Query Methods
5556
- (void)lastAttributedTouchData:(CDVInvokedUrlCommand *)command;
5657

58+
5759
@end

src/ios/BranchSDK.m

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,30 @@ - (void)setDMAParamsForEEA:(CDVInvokedUrlCommand*)command {
319319
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
320320
}
321321

322+
- (void)setConsumerProtectionAttributionLevel:(CDVInvokedUrlCommand*)command {
323+
NSString *level = [command.arguments objectAtIndex:0];
324+
BranchAttributionLevel attributionLevel;
325+
326+
if ([level isEqualToString:@"FULL"]) {
327+
attributionLevel = BranchAttributionLevelFull;
328+
} else if ([level isEqualToString:@"REDUCED"]) {
329+
attributionLevel = BranchAttributionLevelReduced;
330+
} else if ([level isEqualToString:@"MINIMAL"]) {
331+
attributionLevel = BranchAttributionLevelMinimal;
332+
} else if ([level isEqualToString:@"NONE"]) {
333+
attributionLevel = BranchAttributionLevelNone;
334+
} else {
335+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
336+
messageAsString:@"Invalid attribution level"];
337+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
338+
return;
339+
}
340+
341+
[[Branch getInstance] setConsumerProtectionAttributionLevel:attributionLevel];
342+
343+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
344+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
345+
}
322346

323347
#pragma mark - Branch Universal Object Methods
324348

@@ -746,4 +770,6 @@ - (void)getBranchActivityItemWithParams:(CDVInvokedUrlCommand*)command
746770
[self.viewController presentViewController:shareViewController animated:YES completion:nil];
747771
}
748772

773+
774+
749775
@end

0 commit comments

Comments
 (0)