Skip to content

Commit 84de80f

Browse files
committed
Updated enum and request fields
1 parent cb78ae8 commit 84de80f

File tree

7 files changed

+78
-54
lines changed

7 files changed

+78
-54
lines changed

Sources/BranchSDK/BNCPreferenceHelper.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,12 +823,20 @@ - (void) setAdUserDataUsageConsent:(BOOL)hasConsent {
823823
}
824824
}
825825

826-
- (NSInteger)attributionLevel {
827-
return [self readIntegerFromDefaults:BRANCH_PREFS_KEY_ATTRIBUTION_LEVEL];
826+
- (BOOL) attributionLevelInitialized {
827+
@synchronized(self) {
828+
if([self readObjectFromDefaults:BRANCH_PREFS_KEY_ATTRIBUTION_LEVEL])
829+
return YES;
830+
return NO;
831+
}
832+
}
833+
834+
- (BranchAttributionLevel)attributionLevel {
835+
return [self readStringFromDefaults:BRANCH_PREFS_KEY_ATTRIBUTION_LEVEL];
828836
}
829837

830-
- (void)setAttributionLevel:(NSInteger)level {
831-
[self writeIntegerToDefaults:BRANCH_PREFS_KEY_ATTRIBUTION_LEVEL value:level];
838+
- (void)setAttributionLevel:(BranchAttributionLevel)level {
839+
[self writeObjectToDefaults:BRANCH_PREFS_KEY_ATTRIBUTION_LEVEL value:level];
832840
}
833841

834842
- (void) clearTrackingInformation {

Sources/BranchSDK/BNCRequestFactory.m

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ - (NSDictionary *)dataForInstallWithURLString:(NSString *)urlString {
117117
// Add DMA Compliance Params for Google
118118
[self addDMAConsentParamsToJSON:json];
119119

120+
[self addConsumerProtectionAttributionLevel:json];
121+
120122
return json;
121123
}
122124

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

169+
[self addConsumerProtectionAttributionLevel:json];
170+
167171
return json;
168172
}
169173

@@ -342,7 +346,6 @@ - (void)addDMAConsentParamsToJSON:(NSMutableDictionary *)json {
342346
}
343347
}
344348

345-
346349
- (void)addLocalURLToInstallJSON:(NSMutableDictionary *)json {
347350
if ([BNCPasteboard sharedInstance].checkOnInstall) {
348351
NSURL *pasteboardURL = nil;
@@ -414,10 +417,6 @@ - (void)addAppClipDataToJSON:(NSMutableDictionary *)json {
414417
- (void)addDefaultRequestDataToJSON:(NSMutableDictionary *)json {
415418
json[@"branch_key"] = self.branchKey;
416419

417-
if (self.preferenceHelper.attributionLevel != NSNotFound) {
418-
[json bnc_safeSetObject:@(self.preferenceHelper.attributionLevel) forKey:@"consumer_protection_attribution_level"];
419-
}
420-
421420
// omit field if value is NO
422421
if ([self isTrackingDisabled]) {
423422
json[@"tracking_disabled"] = @(1);
@@ -491,6 +490,12 @@ - (void)addDeveloperUserIDToJSON:(NSMutableDictionary *)json {
491490
[json bnc_safeSetObject:self.preferenceHelper.userIdentity forKey:@"identity"];
492491
}
493492

493+
- (void)addConsumerProtectionAttributionLevel:(NSMutableDictionary *)json {
494+
if([self.preferenceHelper attributionLevelInitialized]){
495+
[self safeSetValue:[self.preferenceHelper attributionLevel] forKey:BRANCH_REQUEST_KEY_CPP_LEVEL onDict:json];
496+
}
497+
}
498+
494499
// event
495500
- (void)addV2DictionaryToJSON:(NSMutableDictionary *)json {
496501
NSDictionary *tmp = [self v2dictionary];
@@ -554,6 +559,8 @@ - (NSDictionary *)v2dictionary {
554559
// Add DMA Compliance Params for Google
555560
[self addDMAConsentParamsToJSON:dictionary];
556561

562+
[self addConsumerProtectionAttributionLevel:dictionary];
563+
557564
return dictionary;
558565
}
559566

Sources/BranchSDK/Branch.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484

8585
NSString * const BNCSpotlightFeature = @"spotlight";
8686

87+
BranchAttributionLevel const BranchAttributionLevelFull = @"FULL";
88+
BranchAttributionLevel const BranchAttributionLevelReduced = @"REDUCED";
89+
BranchAttributionLevel const BranchAttributionLevelMinimal = @"MINIMAL";
90+
BranchAttributionLevel const BranchAttributionLevelNone = @"NONE";
91+
8792
#ifndef CSSearchableItemActivityIdentifier
8893
#define CSSearchableItemActivityIdentifier @"kCSSearchableItemActivityIdentifier"
8994
#endif
@@ -542,7 +547,7 @@ + (void) setDMAParamsForEEA:(BOOL)eeaRegion AdPersonalizationConsent:(BOOL)adPer
542547
- (void)setConsumerProtectionAttributionLevel:(BranchAttributionLevel)level {
543548
self.preferenceHelper.attributionLevel = level;
544549

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

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

570575
// Set the flag:
571576
[BNCPreferenceHelper sharedInstance].trackingDisabled = NO;

Sources/BranchSDK/BranchConstants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,4 @@
166166
NSString * const BRANCH_REQUEST_KEY_DMA_AD_PEROSALIZATION = @"dma_ad_personalization";
167167
NSString * const BRANCH_REQUEST_KEY_DMA_AD_USER_DATA = @"dma_ad_user_data";
168168

169+
NSString * const BRANCH_REQUEST_KEY_CPP_LEVEL = @"cpp_level";

Sources/BranchSDK/Private/BranchConstants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,5 @@ extern NSString * const BRANCH_REQUEST_KEY_VALUE_POSTBACK_SEQUENCE_INDEX_2;
167167
extern NSString * const BRANCH_REQUEST_KEY_DMA_EEA;
168168
extern NSString * const BRANCH_REQUEST_KEY_DMA_AD_PEROSALIZATION;
169169
extern NSString * const BRANCH_REQUEST_KEY_DMA_AD_USER_DATA;
170+
171+
extern NSString * const BRANCH_REQUEST_KEY_CPP_LEVEL;

Sources/BranchSDK/Public/BNCPreferenceHelper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);
7676
@property (assign, nonatomic) BOOL adPersonalizationConsent;
7777
@property (assign, nonatomic) BOOL adUserDataUsageConsent;
7878

79-
@property (nonatomic, assign) NSInteger attributionLevel;
79+
@property (nonatomic, assign) NSString *attributionLevel;
8080

8181

8282
- (void) clearTrackingInformation;
@@ -103,5 +103,6 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);
103103
- (void) synchronize; // Flushes preference queue to persistence.
104104
+ (void) clearAll;
105105
- (BOOL) eeaRegionInitialized;
106+
- (BOOL) attributionLevelInitialized;
106107

107108
@end

Sources/BranchSDK/Public/Branch.h

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -816,48 +816,48 @@ Sets a custom base URL for all calls to the Branch API.
816816
/**
817817
* Enumeration representing different levels of consumer protection attribution levels
818818
*/
819-
typedef NS_ENUM(NSUInteger, BranchAttributionLevel) {
820-
/**
821-
* Full:
822-
* - Advertising Ids
823-
* - Device Ids
824-
* - Local IP
825-
* - Persisted Non-Aggregate Ids
826-
* - Persisted Aggregate Ids
827-
* - Ads Postbacks / Webhooks
828-
* - Data Integrations Webhooks
829-
* - SAN Callouts
830-
* - Privacy Frameworks
831-
* - Deep Linking
832-
*/
833-
BranchAttributionLevelFull = 0,
834-
835-
/**
836-
* Reduced:
837-
* - Device Ids
838-
* - Local IP
839-
* - Data Integrations Webhooks
840-
* - Privacy Frameworks
841-
* - Deep Linking
842-
*/
843-
BranchAttributionLevelReduced = 1,
844-
845-
/**
846-
* Minimal:
847-
* - Device Ids
848-
* - Local IP
849-
* - Data Integrations Webhooks
850-
* - Deep Linking
851-
*/
852-
BranchAttributionLevelMinimal = 2,
853-
854-
/**
855-
* None:
856-
* - Only Deterministic Deep Linking
857-
* - Disables all other Branch requests
858-
*/
859-
BranchAttributionLevelNone = 3
860-
};
819+
typedef NSString * BranchAttributionLevel NS_STRING_ENUM;
820+
821+
/**
822+
* Full:
823+
* - Advertising Ids
824+
* - Device Ids
825+
* - Local IP
826+
* - Persisted Non-Aggregate Ids
827+
* - Persisted Aggregate Ids
828+
* - Ads Postbacks / Webhooks
829+
* - Data Integrations Webhooks
830+
* - SAN Callouts
831+
* - Privacy Frameworks
832+
* - Deep Linking
833+
*/
834+
extern BranchAttributionLevel const BranchAttributionLevelFull;
835+
836+
/**
837+
* Reduced:
838+
* - Device Ids
839+
* - Local IP
840+
* - Data Integrations Webhooks
841+
* - Privacy Frameworks
842+
* - Deep Linking
843+
*/
844+
extern BranchAttributionLevel const BranchAttributionLevelReduced;
845+
846+
/**
847+
* Minimal:
848+
* - Device Ids
849+
* - Local IP
850+
* - Data Integrations Webhooks
851+
* - Deep Linking
852+
*/
853+
extern BranchAttributionLevel const BranchAttributionLevelMinimal;
854+
855+
/**
856+
* None:
857+
* - Only Deterministic Deep Linking
858+
* - Disables all other Branch requests
859+
*/
860+
extern BranchAttributionLevel const BranchAttributionLevelNone;
861861

862862

863863
/**

0 commit comments

Comments
 (0)