Skip to content

Commit 5ae2b4d

Browse files
Set cpp level via branch.json (#1456)
1 parent d1b6465 commit 5ae2b4d

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

Sources/BranchSDK/Branch.m

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,20 @@ - (id)initWithInterface:(BNCServerInterface *)interface
256256
if (config.checkPasteboardOnInstall) {
257257
[self checkPasteboardOnInstall];
258258
}
259+
260+
if (config.cppLevel) {
261+
if ([config.cppLevel caseInsensitiveCompare:@"FULL"] == NSOrderedSame) {
262+
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelFull];
263+
} else if ([config.cppLevel caseInsensitiveCompare:@"REDUCED"] == NSOrderedSame) {
264+
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelReduced];
265+
} else if ([config.cppLevel caseInsensitiveCompare:@"MINIMAL"] == NSOrderedSame) {
266+
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelMinimal];
267+
} else if ([config.cppLevel caseInsensitiveCompare:@"NONE"] == NSOrderedSame) {
268+
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelNone];
269+
} else {
270+
NSLog(@"Invalid CPP Level set in branch.json: %@", config.cppLevel);
271+
}
272+
}
259273

260274
return self;
261275
}
@@ -641,7 +655,7 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options automaticallyDispla
641655

642656
#pragma mark - Actual Init Session
643657

644-
- (void)initSessionWithLaunchOptions:(NSDictionary *)options isReferrable:(BOOL)isReferrable explicitlyRequestedReferrable:(BOOL)explicitlyRequestedReferrable automaticallyDisplayController:(BOOL)automaticallyDisplayController registerDeepLinkHandlerUsingBranchUniversalObject:(callbackWithBranchUniversalObject)callback {
658+
- (void)initSessionWithLaunchOptions:(NSDictionary *)options isReferrable:(BOOL)isReferrable explicitlyRequestedReferrable:(BOOL)explicitlyRequestedReferrable automaticallyDisplayController:(BOOL)automaticallyDisplayController registerDeepLinkHandlerUsingBranchUniversalObject:(callbackWithBranchUniversalObject)callback {
645659
[self initSceneSessionWithLaunchOptions:options isReferrable:isReferrable explicitlyRequestedReferrable:explicitlyRequestedReferrable automaticallyDisplayController:automaticallyDisplayController
646660
registerDeepLinkHandler:^(BNCInitSessionResponse * _Nullable initResponse, NSError * _Nullable error) {
647661
if (callback) {
@@ -1116,8 +1130,8 @@ - (NSDictionary *)getFirstReferringParams {
11161130

11171131
if (self.deepLinkDebugParams) {
11181132
NSMutableDictionary* debugInstallParams =
1119-
[[BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.sessionParams]
1120-
mutableCopy];
1133+
[[BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.sessionParams]
1134+
mutableCopy];
11211135
[debugInstallParams addEntriesFromDictionary:self.deepLinkDebugParams];
11221136
return debugInstallParams;
11231137
}
@@ -2060,7 +2074,7 @@ - (void)initUserSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSStr
20602074
// only called from initUserSessionAndCallCallback!
20612075
- (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSString *)sceneIdentifier urlString:(NSString *)urlString {
20622076

2063-
// BranchDelegate willStartSessionWithURL notification
2077+
// BranchDelegate willStartSessionWithURL notification
20642078
NSURL *URL = (self.preferenceHelper.referringURL.length) ? [NSURL URLWithString:self.preferenceHelper.referringURL] : nil;
20652079
if ([self.delegate respondsToSelector:@selector(branch:willStartSessionWithURL:)]) {
20662080
[self.delegate branch:self willStartSessionWithURL:URL];
@@ -2125,7 +2139,7 @@ - (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS
21252139

21262140
[self processNextQueueItem];
21272141
});
2128-
}
2142+
}
21292143
}
21302144

21312145

Sources/BranchSDK/BranchJsonConfig.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
NSString * _Nonnull const BranchJsonConfigEnableLogging = @"enableLogging";
1919
NSString * _Nonnull const BranchJsonConfigCheckPasteboardOnInstall = @"checkPasteboardOnInstall";
2020
NSString * _Nonnull const BranchJsonConfigAPIUrl = @"apiUrl";
21-
21+
NSString * _Nonnull const BranchJsonConfigCPPLevel = @"consumerProtectionAttributionLevel";
2222

2323
@interface BranchJsonConfig()
2424
@property (nonatomic, strong) NSDictionary *configuration;
@@ -163,6 +163,11 @@ - (NSString *)apiUrl
163163
return self[BranchJsonConfigAPIUrl];
164164
}
165165

166+
- (NSString *)cppLevel
167+
{
168+
return self[BranchJsonConfigCPPLevel];
169+
}
170+
166171
- (id)objectForKey:(NSString *)key
167172
{
168173
return self.configuration[key];

Sources/BranchSDK/Private/BranchJsonConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern NSString * _Nonnull const BranchJsonConfigAPIUrl;
3131
@property (nonatomic, readonly, assign) BOOL enableLogging;
3232
@property (nonatomic, readonly, assign) BOOL checkPasteboardOnInstall;
3333
@property (nonatomic, readonly, nullable, copy) NSString *apiUrl;
34+
@property (nonatomic, readonly, nullable, copy) NSString *cppLevel;
3435

3536
- (nullable id)objectForKey:(NSString * _Nonnull)key;
3637
- (nullable id)objectForKeyedSubscript:(NSString * _Nonnull)key;

0 commit comments

Comments
 (0)