|
30 | 30 | import io.branch.referral.util.ContentMetadata; |
31 | 31 | import io.branch.referral.util.CurrencyType; |
32 | 32 | import io.branch.referral.util.ShareSheetStyle; |
| 33 | +import io.branch.referral.BranchAttributionLevel; |
33 | 34 |
|
34 | 35 |
|
35 | 36 | public class BranchSDK extends CordovaPlugin { |
@@ -112,7 +113,14 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo |
112 | 113 | return true; |
113 | 114 | } else { |
114 | 115 | 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")) { |
116 | 124 | cordova.getActivity().runOnUiThread(r); |
117 | 125 | return true; |
118 | 126 | } else if (action.equals("sendBranchEvent")) { |
@@ -698,6 +706,44 @@ public void setDMAParamsForEEA(boolean eeaRegion, boolean adPersonalizationConse |
698 | 706 | Branch.getInstance().setDMAParamsForEEA(eeaRegion, adPersonalizationConsent, adUserDataUsageConsent); |
699 | 707 | } |
700 | 708 |
|
| 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 | + |
701 | 747 | private BranchUniversalObject getContentItem(JSONObject item) throws JSONException { |
702 | 748 | BranchUniversalObject universalObject = new BranchUniversalObject(); |
703 | 749 | ContentMetadata contentMetadata = new ContentMetadata(); |
@@ -1149,11 +1195,15 @@ public void run() { |
1149 | 1195 | showShareSheet(this.args.getInt(0), this.args.getJSONObject(1), this.args.getJSONObject(2), localization); |
1150 | 1196 | } else if (this.action.equals("setDMAParamsForEEA")) { |
1151 | 1197 | 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); |
1152 | 1200 | } |
1153 | 1201 | } |
1154 | 1202 | } catch (JSONException e) { |
1155 | 1203 | e.printStackTrace(); |
1156 | 1204 | } |
1157 | 1205 | } |
1158 | 1206 | } |
| 1207 | + |
| 1208 | + |
1159 | 1209 | } |
0 commit comments