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-2522] Set CPP Level via branch.json #1456

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
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 @@ -632,7 +646,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 @@ -1107,8 +1121,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 @@ -2051,7 +2065,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 @@ -2116,7 +2130,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
Loading