Skip to content

Commit 1e41bc3

Browse files
committed
Update to remove IDs from requests
1 parent 84de80f commit 1e41bc3

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

Sources/BranchSDK/BNCRequestFactory.m

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,12 @@ - (void)addInstrumentationToJSON:(NSMutableDictionary *)json {
480480
// BNCReferringURLUtility requires the endpoint string to determine which query params are applied
481481
- (void)addReferringURLsToJSON:(NSMutableDictionary *)json forEndpoint:(NSString *)endpoint {
482482
// Not a singleton, but BNCReferringURLUtility does pull from storage
483-
BNCReferringURLUtility *utility = [BNCReferringURLUtility new];
484-
NSDictionary *urlQueryParams = [utility referringURLQueryParamsForEndpoint:endpoint];
485-
[json bnc_safeAddEntriesFromDictionary:urlQueryParams];
483+
if ([self.preferenceHelper attributionLevel] == BranchAttributionLevelFull ||
484+
[self.preferenceHelper attributionLevelInitialized] == false) {
485+
BNCReferringURLUtility *utility = [BNCReferringURLUtility new];
486+
NSDictionary *urlQueryParams = [utility referringURLQueryParamsForEndpoint:endpoint];
487+
[json bnc_safeAddEntriesFromDictionary:urlQueryParams];
488+
}
486489
}
487490

488491
// install and open
@@ -491,8 +494,9 @@ - (void)addDeveloperUserIDToJSON:(NSMutableDictionary *)json {
491494
}
492495

493496
- (void)addConsumerProtectionAttributionLevel:(NSMutableDictionary *)json {
494-
if([self.preferenceHelper attributionLevelInitialized]){
495-
[self safeSetValue:[self.preferenceHelper attributionLevel] forKey:BRANCH_REQUEST_KEY_CPP_LEVEL onDict:json];
497+
if ([self.preferenceHelper attributionLevelInitialized]) {
498+
BranchAttributionLevel attributionLevel = [self.preferenceHelper attributionLevel];
499+
[self safeSetValue:attributionLevel forKey:BRANCH_REQUEST_KEY_CPP_LEVEL onDict:json];
496500
}
497501
}
498502

@@ -508,18 +512,28 @@ - (NSDictionary *)v2dictionary {
508512
NSMutableDictionary *dictionary = [NSMutableDictionary new];
509513
@synchronized (self.deviceInfo) {
510514
[self.deviceInfo checkAdvertisingIdentifier];
511-
515+
512516
BOOL disableAdNetworkCallouts = self.preferenceHelper.disableAdNetworkCallouts;
513517
if (disableAdNetworkCallouts) {
514518
dictionary[@"disable_ad_network_callouts"] = [NSNumber numberWithBool:disableAdNetworkCallouts];
515519
}
516-
520+
517521
if (self.preferenceHelper.isDebug) {
518522
dictionary[@"unidentified_device"] = @(YES);
519523
} else {
520-
[dictionary bnc_safeSetObject:self.deviceInfo.vendorId forKey:@"idfv"];
521-
[dictionary bnc_safeSetObject:self.deviceInfo.advertiserId forKey:@"idfa"];
524+
BranchAttributionLevel attributionLevel = [self.preferenceHelper attributionLevel];
525+
526+
if (attributionLevel == BranchAttributionLevelFull ||
527+
[self.preferenceHelper attributionLevelInitialized] == false) {
528+
[dictionary bnc_safeSetObject:self.deviceInfo.advertiserId forKey:@"idfa"];
529+
}
530+
531+
if (attributionLevel != BranchAttributionLevelNone ||
532+
[self.preferenceHelper attributionLevelInitialized] == false) {
533+
[dictionary bnc_safeSetObject:self.deviceInfo.vendorId forKey:@"idfv"];
534+
}
522535
}
536+
523537
[dictionary bnc_safeSetObject:self.deviceInfo.anonId forKey:@"anon_id"];
524538
[dictionary bnc_safeSetObject:self.deviceInfo.localIPAddress forKey:@"local_ip"];
525539

@@ -576,20 +590,27 @@ - (void)updateDeviceInfoToMutableDictionary:(NSMutableDictionary *)dict {
576590
if (![self isTrackingDisabled]) {
577591
[self.deviceInfo checkAdvertisingIdentifier];
578592

593+
// Only include hardware ID fields for Full Attribution Level
594+
if ([self.preferenceHelper attributionLevel] == BranchAttributionLevelFull) {
595+
579596
// hardware id information. idfa, idfv or random
580597
NSString *hardwareId = [self.deviceInfo.hardwareId copy];
581598
NSString *hardwareIdType = [self.deviceInfo.hardwareIdType copy];
582599
NSNumber *isRealHardwareId = @(self.deviceInfo.isRealHardwareId);
583-
if (hardwareId != nil && hardwareIdType != nil && isRealHardwareId != nil) {
584-
dict[BRANCH_REQUEST_KEY_HARDWARE_ID] = hardwareId;
585-
dict[BRANCH_REQUEST_KEY_HARDWARE_ID_TYPE] = hardwareIdType;
586-
dict[BRANCH_REQUEST_KEY_IS_HARDWARE_ID_REAL] = isRealHardwareId;
600+
601+
if (hardwareId != nil && hardwareIdType != nil && isRealHardwareId != nil) {
602+
dict[BRANCH_REQUEST_KEY_HARDWARE_ID] = hardwareId;
603+
dict[BRANCH_REQUEST_KEY_HARDWARE_ID_TYPE] = hardwareIdType;
604+
dict[BRANCH_REQUEST_KEY_IS_HARDWARE_ID_REAL] = isRealHardwareId;
605+
}
606+
[self safeSetValue:self.deviceInfo.advertiserId forKey:@"idfa" onDict:dict];
587607
}
588-
589-
// idfv is duplicated in the hardware id field when idfa is unavailable
590-
[self safeSetValue:self.deviceInfo.vendorId forKey:BRANCH_REQUEST_KEY_IOS_VENDOR_ID onDict:dict];
591-
// idfa is only in the hardware id field
592-
// [self safeSetValue:deviceInfo.advertiserId forKey:@"idfa" onDict:dict];
608+
609+
// Only include hardware ID fields for attribution levels greater than None
610+
if ([self.preferenceHelper attributionLevel] != BranchAttributionLevelNone) {
611+
[self safeSetValue:self.deviceInfo.vendorId forKey:BRANCH_REQUEST_KEY_IOS_VENDOR_ID onDict:dict];
612+
}
613+
593614
[self safeSetValue:self.deviceInfo.anonId forKey:@"anon_id" onDict:dict];
594615

595616
[self safeSetValue:[self.deviceInfo localIPAddress] forKey:@"local_ip" onDict:dict];

Sources/BranchSDK/Branch.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
BranchAttributionLevel const BranchAttributionLevelMinimal = @"MINIMAL";
9090
BranchAttributionLevel const BranchAttributionLevelNone = @"NONE";
9191

92+
9293
#ifndef CSSearchableItemActivityIdentifier
9394
#define CSSearchableItemActivityIdentifier @"kCSSearchableItemActivityIdentifier"
9495
#endif

0 commit comments

Comments
 (0)