Skip to content

Commit

Permalink
Updated enum and request fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nsingh-branch committed Jul 30, 2024
1 parent cb78ae8 commit 84de80f
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 54 deletions.
16 changes: 12 additions & 4 deletions Sources/BranchSDK/BNCPreferenceHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -823,12 +823,20 @@ - (void) setAdUserDataUsageConsent:(BOOL)hasConsent {
}
}

- (NSInteger)attributionLevel {
return [self readIntegerFromDefaults:BRANCH_PREFS_KEY_ATTRIBUTION_LEVEL];
- (BOOL) attributionLevelInitialized {
@synchronized(self) {
if([self readObjectFromDefaults:BRANCH_PREFS_KEY_ATTRIBUTION_LEVEL])
return YES;
return NO;
}
}

- (BranchAttributionLevel)attributionLevel {
return [self readStringFromDefaults:BRANCH_PREFS_KEY_ATTRIBUTION_LEVEL];
}

- (void)setAttributionLevel:(NSInteger)level {
[self writeIntegerToDefaults:BRANCH_PREFS_KEY_ATTRIBUTION_LEVEL value:level];
- (void)setAttributionLevel:(BranchAttributionLevel)level {
[self writeObjectToDefaults:BRANCH_PREFS_KEY_ATTRIBUTION_LEVEL value:level];
}

- (void) clearTrackingInformation {
Expand Down
17 changes: 12 additions & 5 deletions Sources/BranchSDK/BNCRequestFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ - (NSDictionary *)dataForInstallWithURLString:(NSString *)urlString {
// Add DMA Compliance Params for Google
[self addDMAConsentParamsToJSON:json];

[self addConsumerProtectionAttributionLevel:json];

return json;
}

Expand Down Expand Up @@ -164,6 +166,8 @@ - (NSDictionary *)dataForOpenWithURLString:(NSString *)urlString {
// Add DMA Compliance Params for Google
[self addDMAConsentParamsToJSON:json];

[self addConsumerProtectionAttributionLevel:json];

return json;
}

Expand Down Expand Up @@ -342,7 +346,6 @@ - (void)addDMAConsentParamsToJSON:(NSMutableDictionary *)json {
}
}


- (void)addLocalURLToInstallJSON:(NSMutableDictionary *)json {
if ([BNCPasteboard sharedInstance].checkOnInstall) {
NSURL *pasteboardURL = nil;
Expand Down Expand Up @@ -414,10 +417,6 @@ - (void)addAppClipDataToJSON:(NSMutableDictionary *)json {
- (void)addDefaultRequestDataToJSON:(NSMutableDictionary *)json {
json[@"branch_key"] = self.branchKey;

if (self.preferenceHelper.attributionLevel != NSNotFound) {
[json bnc_safeSetObject:@(self.preferenceHelper.attributionLevel) forKey:@"consumer_protection_attribution_level"];
}

// omit field if value is NO
if ([self isTrackingDisabled]) {
json[@"tracking_disabled"] = @(1);
Expand Down Expand Up @@ -491,6 +490,12 @@ - (void)addDeveloperUserIDToJSON:(NSMutableDictionary *)json {
[json bnc_safeSetObject:self.preferenceHelper.userIdentity forKey:@"identity"];
}

- (void)addConsumerProtectionAttributionLevel:(NSMutableDictionary *)json {
if([self.preferenceHelper attributionLevelInitialized]){
[self safeSetValue:[self.preferenceHelper attributionLevel] forKey:BRANCH_REQUEST_KEY_CPP_LEVEL onDict:json];
}
}

// event
- (void)addV2DictionaryToJSON:(NSMutableDictionary *)json {
NSDictionary *tmp = [self v2dictionary];
Expand Down Expand Up @@ -554,6 +559,8 @@ - (NSDictionary *)v2dictionary {
// Add DMA Compliance Params for Google
[self addDMAConsentParamsToJSON:dictionary];

[self addConsumerProtectionAttributionLevel:dictionary];

return dictionary;
}

Expand Down
9 changes: 7 additions & 2 deletions Sources/BranchSDK/Branch.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@

NSString * const BNCSpotlightFeature = @"spotlight";

BranchAttributionLevel const BranchAttributionLevelFull = @"FULL";
BranchAttributionLevel const BranchAttributionLevelReduced = @"REDUCED";
BranchAttributionLevel const BranchAttributionLevelMinimal = @"MINIMAL";
BranchAttributionLevel const BranchAttributionLevelNone = @"NONE";

#ifndef CSSearchableItemActivityIdentifier
#define CSSearchableItemActivityIdentifier @"kCSSearchableItemActivityIdentifier"
#endif
Expand Down Expand Up @@ -542,7 +547,7 @@ + (void) setDMAParamsForEEA:(BOOL)eeaRegion AdPersonalizationConsent:(BOOL)adPer
- (void)setConsumerProtectionAttributionLevel:(BranchAttributionLevel)level {
self.preferenceHelper.attributionLevel = level;

[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Setting Consumer Protection Attribution Level to %lu", (unsigned long)level] error:nil];
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Setting Consumer Protection Attribution Level to %@", level] error:nil];

//Set tracking to disabled if consumer protection attribution level is changed to BranchAttributionLevelNone. Otherwise, keep tracking enabled.
if (level == BranchAttributionLevelNone) {
Expand All @@ -565,7 +570,7 @@ - (void)setConsumerProtectionAttributionLevel:(BranchAttributionLevel)level {
} else {
if ([Branch trackingDisabled]) {
//Enable Tracking
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Enabling attribution events due to Consumer Protection Attribution Level being %lu.", (unsigned long)level] error:nil];
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Enabling attribution events due to Consumer Protection Attribution Level being %@.", level] error:nil];

// Set the flag:
[BNCPreferenceHelper sharedInstance].trackingDisabled = NO;
Expand Down
1 change: 1 addition & 0 deletions Sources/BranchSDK/BranchConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,4 @@
NSString * const BRANCH_REQUEST_KEY_DMA_AD_PEROSALIZATION = @"dma_ad_personalization";
NSString * const BRANCH_REQUEST_KEY_DMA_AD_USER_DATA = @"dma_ad_user_data";

NSString * const BRANCH_REQUEST_KEY_CPP_LEVEL = @"cpp_level";
2 changes: 2 additions & 0 deletions Sources/BranchSDK/Private/BranchConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,5 @@ extern NSString * const BRANCH_REQUEST_KEY_VALUE_POSTBACK_SEQUENCE_INDEX_2;
extern NSString * const BRANCH_REQUEST_KEY_DMA_EEA;
extern NSString * const BRANCH_REQUEST_KEY_DMA_AD_PEROSALIZATION;
extern NSString * const BRANCH_REQUEST_KEY_DMA_AD_USER_DATA;

extern NSString * const BRANCH_REQUEST_KEY_CPP_LEVEL;
3 changes: 2 additions & 1 deletion Sources/BranchSDK/Public/BNCPreferenceHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);
@property (assign, nonatomic) BOOL adPersonalizationConsent;
@property (assign, nonatomic) BOOL adUserDataUsageConsent;

@property (nonatomic, assign) NSInteger attributionLevel;
@property (nonatomic, assign) NSString *attributionLevel;


- (void) clearTrackingInformation;
Expand All @@ -103,5 +103,6 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);
- (void) synchronize; // Flushes preference queue to persistence.
+ (void) clearAll;
- (BOOL) eeaRegionInitialized;
- (BOOL) attributionLevelInitialized;

@end
84 changes: 42 additions & 42 deletions Sources/BranchSDK/Public/Branch.h
Original file line number Diff line number Diff line change
Expand Up @@ -816,48 +816,48 @@ Sets a custom base URL for all calls to the Branch API.
/**
* Enumeration representing different levels of consumer protection attribution levels
*/
typedef NS_ENUM(NSUInteger, BranchAttributionLevel) {
/**
* Full:
* - Advertising Ids
* - Device Ids
* - Local IP
* - Persisted Non-Aggregate Ids
* - Persisted Aggregate Ids
* - Ads Postbacks / Webhooks
* - Data Integrations Webhooks
* - SAN Callouts
* - Privacy Frameworks
* - Deep Linking
*/
BranchAttributionLevelFull = 0,
/**
* Reduced:
* - Device Ids
* - Local IP
* - Data Integrations Webhooks
* - Privacy Frameworks
* - Deep Linking
*/
BranchAttributionLevelReduced = 1,
/**
* Minimal:
* - Device Ids
* - Local IP
* - Data Integrations Webhooks
* - Deep Linking
*/
BranchAttributionLevelMinimal = 2,
/**
* None:
* - Only Deterministic Deep Linking
* - Disables all other Branch requests
*/
BranchAttributionLevelNone = 3
};
typedef NSString * BranchAttributionLevel NS_STRING_ENUM;

/**
* Full:
* - Advertising Ids
* - Device Ids
* - Local IP
* - Persisted Non-Aggregate Ids
* - Persisted Aggregate Ids
* - Ads Postbacks / Webhooks
* - Data Integrations Webhooks
* - SAN Callouts
* - Privacy Frameworks
* - Deep Linking
*/
extern BranchAttributionLevel const BranchAttributionLevelFull;

/**
* Reduced:
* - Device Ids
* - Local IP
* - Data Integrations Webhooks
* - Privacy Frameworks
* - Deep Linking
*/
extern BranchAttributionLevel const BranchAttributionLevelReduced;

/**
* Minimal:
* - Device Ids
* - Local IP
* - Data Integrations Webhooks
* - Deep Linking
*/
extern BranchAttributionLevel const BranchAttributionLevelMinimal;

/**
* None:
* - Only Deterministic Deep Linking
* - Disables all other Branch requests
*/
extern BranchAttributionLevel const BranchAttributionLevelNone;


/**
Expand Down

0 comments on commit 84de80f

Please sign in to comment.