diff --git a/Branch-SDK/src/main/java/io/branch/referral/Branch.java b/Branch-SDK/src/main/java/io/branch/referral/Branch.java index aa2a5945b..5099c6a52 100644 --- a/Branch-SDK/src/main/java/io/branch/referral/Branch.java +++ b/Branch-SDK/src/main/java/io/branch/referral/Branch.java @@ -381,6 +381,8 @@ synchronized public static Branch getAutoInstance(@NonNull Context context) { BranchUtil.setFbAppIdFromConfig(context); + BranchUtil.setCPPLevel(context); + BranchUtil.setTestMode(BranchUtil.checkTestMode(context)); branchReferral_ = initBranchSDK(context, BranchUtil.readBranchKey(context)); getPreinstallSystemData(branchReferral_, context); @@ -410,6 +412,7 @@ public static Branch getAutoInstance(@NonNull Context context, @NonNull String b BranchUtil.setAPIBaseUrlFromConfig(context); BranchUtil.setFbAppIdFromConfig(context); + BranchUtil.setCPPLevel(context); BranchUtil.setTestMode(BranchUtil.checkTestMode(context)); // If a Branch key is passed already use it. Else read the key if (!isValidBranchKey(branchKey)) { diff --git a/Branch-SDK/src/main/java/io/branch/referral/BranchJsonConfig.java b/Branch-SDK/src/main/java/io/branch/referral/BranchJsonConfig.java index cf3647f22..ba6d23cbf 100644 --- a/Branch-SDK/src/main/java/io/branch/referral/BranchJsonConfig.java +++ b/Branch-SDK/src/main/java/io/branch/referral/BranchJsonConfig.java @@ -31,7 +31,8 @@ public enum BranchJsonKey { enableLogging, deferInitForPluginRuntime, apiUrl, - fbAppId + fbAppId, + cppLevel } /* @@ -48,7 +49,8 @@ public enum BranchJsonKey { "enableLogging": true, "deferInitForPluginRuntime": true, "apiUrl": "https://api2.branch.io", - "fbAppId": "xyz123456789" + "fbAppId": "xyz123456789", + "consumerProtectionAttributionLevel: "Reduced" } */ @@ -223,4 +225,23 @@ public String getFbAppId() { return null; } } + + @Nullable + public String getConsumerProtectionAttributionLevel() { + if (mConfiguration == null) { + return null; + } + + try { + if (!mConfiguration.has(BranchJsonKey.cppLevel.toString())) { + return null; + } + + return mConfiguration.getString(BranchJsonKey.cppLevel.toString()); + } + catch (JSONException exception) { + Log.e(TAG, "Error parsing branch.json: " + exception.getMessage()); + return null; + } + } } diff --git a/Branch-SDK/src/main/java/io/branch/referral/BranchUtil.java b/Branch-SDK/src/main/java/io/branch/referral/BranchUtil.java index 961cc6347..5c1dab9eb 100644 --- a/Branch-SDK/src/main/java/io/branch/referral/BranchUtil.java +++ b/Branch-SDK/src/main/java/io/branch/referral/BranchUtil.java @@ -156,6 +156,12 @@ public static void setFbAppIdFromConfig(Context context) { } } + public static void setCPPLevel(Context context) { + BranchJsonConfig jsonConfig = BranchJsonConfig.getInstance(context); + Defines.BranchAttributionLevel cppLevel = Defines.BranchAttributionLevel.valueOf(jsonConfig.getConsumerProtectionAttributionLevel()); + Branch.getInstance().setConsumerProtectionAttributionLevel(cppLevel); + } + /** * Get the value of "io.branch.sdk.TestMode" entry in application manifest or from String res. * This value can be overridden via. {@link Branch#enableTestMode()}