Skip to content

Commit 3812f8b

Browse files
[SDK-2523] Added CPP level to branch.json (#1234)
Added CPP level to branch.json
1 parent fd90edd commit 3812f8b

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

Branch-SDK/src/main/java/io/branch/referral/Branch.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ synchronized public static Branch getAutoInstance(@NonNull Context context) {
381381

382382
BranchUtil.setFbAppIdFromConfig(context);
383383

384+
BranchUtil.setCPPLevel(context);
385+
384386
BranchUtil.setTestMode(BranchUtil.checkTestMode(context));
385387
branchReferral_ = initBranchSDK(context, BranchUtil.readBranchKey(context));
386388
getPreinstallSystemData(branchReferral_, context);
@@ -410,6 +412,7 @@ public static Branch getAutoInstance(@NonNull Context context, @NonNull String b
410412

411413
BranchUtil.setAPIBaseUrlFromConfig(context);
412414
BranchUtil.setFbAppIdFromConfig(context);
415+
BranchUtil.setCPPLevel(context);
413416
BranchUtil.setTestMode(BranchUtil.checkTestMode(context));
414417
// If a Branch key is passed already use it. Else read the key
415418
if (!isValidBranchKey(branchKey)) {

Branch-SDK/src/main/java/io/branch/referral/BranchJsonConfig.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public enum BranchJsonKey {
3131
enableLogging,
3232
deferInitForPluginRuntime,
3333
apiUrl,
34-
fbAppId
34+
fbAppId,
35+
cppLevel
3536
}
3637

3738
/*
@@ -48,7 +49,8 @@ public enum BranchJsonKey {
4849
"enableLogging": true,
4950
"deferInitForPluginRuntime": true,
5051
"apiUrl": "https://api2.branch.io",
51-
"fbAppId": "xyz123456789"
52+
"fbAppId": "xyz123456789",
53+
"consumerProtectionAttributionLevel: "Reduced"
5254
}
5355
*/
5456

@@ -223,4 +225,23 @@ public String getFbAppId() {
223225
return null;
224226
}
225227
}
228+
229+
@Nullable
230+
public String getConsumerProtectionAttributionLevel() {
231+
if (mConfiguration == null) {
232+
return null;
233+
}
234+
235+
try {
236+
if (!mConfiguration.has(BranchJsonKey.cppLevel.toString())) {
237+
return null;
238+
}
239+
240+
return mConfiguration.getString(BranchJsonKey.cppLevel.toString());
241+
}
242+
catch (JSONException exception) {
243+
Log.e(TAG, "Error parsing branch.json: " + exception.getMessage());
244+
return null;
245+
}
246+
}
226247
}

Branch-SDK/src/main/java/io/branch/referral/BranchUtil.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ public static void setFbAppIdFromConfig(Context context) {
156156
}
157157
}
158158

159+
public static void setCPPLevel(Context context) {
160+
BranchJsonConfig jsonConfig = BranchJsonConfig.getInstance(context);
161+
Defines.BranchAttributionLevel cppLevel = Defines.BranchAttributionLevel.valueOf(jsonConfig.getConsumerProtectionAttributionLevel());
162+
Branch.getInstance().setConsumerProtectionAttributionLevel(cppLevel);
163+
}
164+
159165
/**
160166
* Get the value of "io.branch.sdk.TestMode" entry in application manifest or from String res.
161167
* This value can be overridden via. {@link Branch#enableTestMode()}

0 commit comments

Comments
 (0)