diff --git a/Sources/BranchSDK/Branch.m b/Sources/BranchSDK/Branch.m index a0036f74c..6d552fec7 100644 --- a/Sources/BranchSDK/Branch.m +++ b/Sources/BranchSDK/Branch.m @@ -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; } @@ -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) { @@ -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; } @@ -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]; @@ -2125,7 +2139,7 @@ - (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS [self processNextQueueItem]; }); - } + } } diff --git a/Sources/BranchSDK/BranchJsonConfig.m b/Sources/BranchSDK/BranchJsonConfig.m index a27850daa..649f0e766 100644 --- a/Sources/BranchSDK/BranchJsonConfig.m +++ b/Sources/BranchSDK/BranchJsonConfig.m @@ -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; @@ -163,6 +163,11 @@ - (NSString *)apiUrl return self[BranchJsonConfigAPIUrl]; } +- (NSString *)cppLevel +{ + return self[BranchJsonConfigCPPLevel]; +} + - (id)objectForKey:(NSString *)key { return self.configuration[key]; diff --git a/Sources/BranchSDK/Private/BranchJsonConfig.h b/Sources/BranchSDK/Private/BranchJsonConfig.h index 425d589d0..db15c98a9 100644 --- a/Sources/BranchSDK/Private/BranchJsonConfig.h +++ b/Sources/BranchSDK/Private/BranchJsonConfig.h @@ -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;