Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-2523] Added CPP level to branch.json #1234

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Branch-SDK/src/main/java/io/branch/referral/Branch.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down
25 changes: 23 additions & 2 deletions Branch-SDK/src/main/java/io/branch/referral/BranchJsonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public enum BranchJsonKey {
enableLogging,
deferInitForPluginRuntime,
apiUrl,
fbAppId
fbAppId,
cppLevel
}

/*
Expand All @@ -48,7 +49,8 @@ public enum BranchJsonKey {
"enableLogging": true,
"deferInitForPluginRuntime": true,
"apiUrl": "https://api2.branch.io",
"fbAppId": "xyz123456789"
"fbAppId": "xyz123456789",
"consumerProtectionAttributionLevel: "Reduced"
}
*/

Expand Down Expand Up @@ -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;
}
}
}
6 changes: 6 additions & 0 deletions Branch-SDK/src/main/java/io/branch/referral/BranchUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand Down
Loading