Skip to content

Commit

Permalink
Updated Params Name and All DMA params will be send to Server even if…
Browse files Browse the repository at this point in the history
… EEA is false
  • Loading branch information
NidhiDixit09 committed Feb 13, 2024
1 parent a14a3d7 commit 5f4dbcb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 37 deletions.
20 changes: 10 additions & 10 deletions BranchSDK/BNCPreferenceHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@

static NSString * const BRANCH_PREFS_KEY_LOG_IAP_AS_EVENTS = @"bnc_log_iap_as_events";

static NSString * const BRANCH_PREFS_KEY_EEA_REGION = @"bnc_eea_region";
static NSString * const BRANCH_PREFS_KEY_AD_PEROSALIZATION_CONSENT = @"bnc_ad_personalization_consent";
static NSString * const BRANCH_PREFS_KEY_AD_USER_DATA_USAGE_CONSENT = @"bnc_ad_user_data_usage_consent";
static NSString * const BRANCH_PREFS_KEY_DMA_EEA = @"bnc_dma_eea";
static NSString * const BRANCH_PREFS_KEY_DMA_AD_PEROSALIZATION = @"bnc_dma_ad_personalization";
static NSString * const BRANCH_PREFS_KEY_DMA_AD_USER_DATA = @"bnc_dma_ad_user_data";


NSURL* /* _Nonnull */ BNCURLForBranchDirectory_Unthreaded(void);
Expand Down Expand Up @@ -800,15 +800,15 @@ - (void) setInvokeRegisterApp:(BOOL)invoke {

- (BOOL) eeaRegionInitialized {
@synchronized(self) {
if([self readObjectFromDefaults:BRANCH_PREFS_KEY_EEA_REGION])
if([self readObjectFromDefaults:BRANCH_PREFS_KEY_DMA_EEA])
return true;
return false;
}
}

- (BOOL) eeaRegion {
@synchronized(self) {
NSNumber *b = (id) [self readObjectFromDefaults:BRANCH_PREFS_KEY_EEA_REGION];
NSNumber *b = (id) [self readObjectFromDefaults:BRANCH_PREFS_KEY_DMA_EEA];
if ([b isKindOfClass:NSNumber.class]) return [b boolValue];
return false;
}
Expand All @@ -817,13 +817,13 @@ - (BOOL) eeaRegion {
- (void) setEeaRegion:(BOOL)isEEARegion {
@synchronized(self) {
NSNumber *b = [NSNumber numberWithBool:isEEARegion];
[self writeObjectToDefaults:BRANCH_PREFS_KEY_EEA_REGION value:b];
[self writeObjectToDefaults:BRANCH_PREFS_KEY_DMA_EEA value:b];
}
}

- (BOOL) adPersonalizationConsent {
@synchronized(self) {
NSNumber *b = (id) [self readObjectFromDefaults:BRANCH_PREFS_KEY_AD_PEROSALIZATION_CONSENT];
NSNumber *b = (id) [self readObjectFromDefaults:BRANCH_PREFS_KEY_DMA_AD_PEROSALIZATION];
if ([b isKindOfClass:NSNumber.class]) return [b boolValue];
return false;
}
Expand All @@ -832,13 +832,13 @@ - (BOOL) adPersonalizationConsent {
- (void) setAdPersonalizationConsent:(BOOL)hasConsent {
@synchronized(self) {
NSNumber *b = [NSNumber numberWithBool:hasConsent];
[self writeObjectToDefaults:BRANCH_PREFS_KEY_AD_PEROSALIZATION_CONSENT value:b];
[self writeObjectToDefaults:BRANCH_PREFS_KEY_DMA_AD_PEROSALIZATION value:b];
}
}

- (BOOL) adUserDataUsageConsent {
@synchronized(self) {
NSNumber *b = (id) [self readObjectFromDefaults:BRANCH_PREFS_KEY_AD_USER_DATA_USAGE_CONSENT];
NSNumber *b = (id) [self readObjectFromDefaults:BRANCH_PREFS_KEY_DMA_AD_USER_DATA];
if ([b isKindOfClass:NSNumber.class]) return [b boolValue];
return false;
}
Expand All @@ -847,7 +847,7 @@ - (BOOL) adUserDataUsageConsent {
- (void) setAdUserDataUsageConsent:(BOOL)hasConsent {
@synchronized(self) {
NSNumber *b = [NSNumber numberWithBool:hasConsent];
[self writeObjectToDefaults:BRANCH_PREFS_KEY_AD_USER_DATA_USAGE_CONSENT value:b];
[self writeObjectToDefaults:BRANCH_PREFS_KEY_DMA_AD_USER_DATA value:b];
}
}

Expand Down
24 changes: 3 additions & 21 deletions BranchSDK/BNCRequestFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -329,27 +329,9 @@ - (void)addPartnerParametersToJSON:(NSMutableDictionary *)json {
- (void)addDMAConsentParamsToJSON:(NSMutableDictionary *)json {

if([self.preferenceHelper eeaRegionInitialized]){

BOOL isEEARegion = [self.preferenceHelper eeaRegion];
BOOL hasAdPersonalizationConsent = [self.preferenceHelper adPersonalizationConsent];
BOOL hasAdUserDataUsageConsent = [self.preferenceHelper adUserDataUsageConsent];

[self safeSetValue:@(isEEARegion) forKey:BRANCH_REQUEST_KEY_EEA_REGION onDict:json];

// Send adPersonalizationConsent and adUserDataUsageConsent only if
// eeaRegion is true OR
// eeaRegion is false but adPersonalizationConsent/adUserDataUsageConsent is also false
if (isEEARegion) {
[self safeSetValue:@(hasAdPersonalizationConsent) forKey:BRANCH_REQUEST_KEY_AD_PEROSALIZATION_CONSENT onDict:json];
[self safeSetValue:@(hasAdUserDataUsageConsent) forKey:BRANCH_REQUEST_KEY_AD_USER_DATA_USAGE_CONSENT onDict:json];
} else {
if (!hasAdPersonalizationConsent) {
[self safeSetValue:@(hasAdPersonalizationConsent) forKey:BRANCH_REQUEST_KEY_AD_PEROSALIZATION_CONSENT onDict:json];
}
if (!hasAdUserDataUsageConsent) {
[self safeSetValue:@(hasAdUserDataUsageConsent) forKey:BRANCH_REQUEST_KEY_AD_USER_DATA_USAGE_CONSENT onDict:json];
}
}
[self safeSetValue:@([self.preferenceHelper eeaRegion]) forKey:BRANCH_REQUEST_KEY_DMA_EEA onDict:json];
[self safeSetValue:@([self.preferenceHelper adPersonalizationConsent]) forKey:BRANCH_REQUEST_KEY_DMA_AD_PEROSALIZATION onDict:json];
[self safeSetValue:@([self.preferenceHelper adUserDataUsageConsent]) forKey:BRANCH_REQUEST_KEY_DMA_AD_USER_DATA onDict:json];
}
}

Expand Down
6 changes: 3 additions & 3 deletions BranchSDK/BranchConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,6 @@ extern NSString * const BRANCH_REQUEST_KEY_VALUE_POSTBACK_SEQUENCE_INDEX_0;
extern NSString * const BRANCH_REQUEST_KEY_VALUE_POSTBACK_SEQUENCE_INDEX_1;
extern NSString * const BRANCH_REQUEST_KEY_VALUE_POSTBACK_SEQUENCE_INDEX_2;

extern NSString * const BRANCH_REQUEST_KEY_EEA_REGION;
extern NSString * const BRANCH_REQUEST_KEY_AD_PEROSALIZATION_CONSENT;
extern NSString * const BRANCH_REQUEST_KEY_AD_USER_DATA_USAGE_CONSENT;
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;
6 changes: 3 additions & 3 deletions BranchSDK/BranchConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
NSString * const BRANCH_REQUEST_KEY_VALUE_POSTBACK_SEQUENCE_INDEX_1 = @"postback-sequence-index-1";
NSString * const BRANCH_REQUEST_KEY_VALUE_POSTBACK_SEQUENCE_INDEX_2 = @"postback-sequence-index-2";

NSString * const BRANCH_REQUEST_KEY_EEA_REGION = @"dma_eea_region";
NSString * const BRANCH_REQUEST_KEY_AD_PEROSALIZATION_CONSENT = @"dma_ad_personalization_consent";
NSString * const BRANCH_REQUEST_KEY_AD_USER_DATA_USAGE_CONSENT = @"dma_ad_user_data_usage_consent";
NSString * const BRANCH_REQUEST_KEY_DMA_EEA = @"dma_eea";
NSString * const BRANCH_REQUEST_KEY_DMA_AD_PEROSALIZATION = @"dma_ad_personalization";
NSString * const BRANCH_REQUEST_KEY_DMA_AD_USER_DATA = @"dma_ad_user_data";

0 comments on commit 5f4dbcb

Please sign in to comment.