Skip to content

Commit

Permalink
Set cpp level via branch.json (#1456)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsingh-branch authored Dec 19, 2024
1 parent d1b6465 commit 5ae2b4d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
24 changes: 19 additions & 5 deletions Sources/BranchSDK/Branch.m
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,20 @@ - (id)initWithInterface:(BNCServerInterface *)interface
if (config.checkPasteboardOnInstall) {
[self checkPasteboardOnInstall];
}

if (config.cppLevel) {
if ([config.cppLevel caseInsensitiveCompare:@"FULL"] == NSOrderedSame) {
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelFull];
} else if ([config.cppLevel caseInsensitiveCompare:@"REDUCED"] == NSOrderedSame) {
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelReduced];
} else if ([config.cppLevel caseInsensitiveCompare:@"MINIMAL"] == NSOrderedSame) {
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelMinimal];
} else if ([config.cppLevel caseInsensitiveCompare:@"NONE"] == NSOrderedSame) {
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelNone];
} else {
NSLog(@"Invalid CPP Level set in branch.json: %@", config.cppLevel);
}
}

return self;
}
Expand Down Expand Up @@ -641,7 +655,7 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options automaticallyDispla

#pragma mark - Actual Init Session

- (void)initSessionWithLaunchOptions:(NSDictionary *)options isReferrable:(BOOL)isReferrable explicitlyRequestedReferrable:(BOOL)explicitlyRequestedReferrable automaticallyDisplayController:(BOOL)automaticallyDisplayController registerDeepLinkHandlerUsingBranchUniversalObject:(callbackWithBranchUniversalObject)callback {
- (void)initSessionWithLaunchOptions:(NSDictionary *)options isReferrable:(BOOL)isReferrable explicitlyRequestedReferrable:(BOOL)explicitlyRequestedReferrable automaticallyDisplayController:(BOOL)automaticallyDisplayController registerDeepLinkHandlerUsingBranchUniversalObject:(callbackWithBranchUniversalObject)callback {
[self initSceneSessionWithLaunchOptions:options isReferrable:isReferrable explicitlyRequestedReferrable:explicitlyRequestedReferrable automaticallyDisplayController:automaticallyDisplayController
registerDeepLinkHandler:^(BNCInitSessionResponse * _Nullable initResponse, NSError * _Nullable error) {
if (callback) {
Expand Down Expand Up @@ -1116,8 +1130,8 @@ - (NSDictionary *)getFirstReferringParams {

if (self.deepLinkDebugParams) {
NSMutableDictionary* debugInstallParams =
[[BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.sessionParams]
mutableCopy];
[[BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.sessionParams]
mutableCopy];
[debugInstallParams addEntriesFromDictionary:self.deepLinkDebugParams];
return debugInstallParams;
}
Expand Down Expand Up @@ -2060,7 +2074,7 @@ - (void)initUserSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSStr
// only called from initUserSessionAndCallCallback!
- (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSString *)sceneIdentifier urlString:(NSString *)urlString {

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

[self processNextQueueItem];
});
}
}
}


Expand Down
7 changes: 6 additions & 1 deletion Sources/BranchSDK/BranchJsonConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
NSString * _Nonnull const BranchJsonConfigEnableLogging = @"enableLogging";
NSString * _Nonnull const BranchJsonConfigCheckPasteboardOnInstall = @"checkPasteboardOnInstall";
NSString * _Nonnull const BranchJsonConfigAPIUrl = @"apiUrl";

NSString * _Nonnull const BranchJsonConfigCPPLevel = @"consumerProtectionAttributionLevel";

@interface BranchJsonConfig()
@property (nonatomic, strong) NSDictionary *configuration;
Expand Down Expand Up @@ -163,6 +163,11 @@ - (NSString *)apiUrl
return self[BranchJsonConfigAPIUrl];
}

- (NSString *)cppLevel
{
return self[BranchJsonConfigCPPLevel];
}

- (id)objectForKey:(NSString *)key
{
return self.configuration[key];
Expand Down
1 change: 1 addition & 0 deletions Sources/BranchSDK/Private/BranchJsonConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extern NSString * _Nonnull const BranchJsonConfigAPIUrl;
@property (nonatomic, readonly, assign) BOOL enableLogging;
@property (nonatomic, readonly, assign) BOOL checkPasteboardOnInstall;
@property (nonatomic, readonly, nullable, copy) NSString *apiUrl;
@property (nonatomic, readonly, nullable, copy) NSString *cppLevel;

- (nullable id)objectForKey:(NSString * _Nonnull)key;
- (nullable id)objectForKeyedSubscript:(NSString * _Nonnull)key;
Expand Down

0 comments on commit 5ae2b4d

Please sign in to comment.