Skip to content

Commit

Permalink
Update to remove IDs from requests
Browse files Browse the repository at this point in the history
  • Loading branch information
nsingh-branch committed Oct 28, 2024
1 parent 84de80f commit 1e41bc3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
57 changes: 39 additions & 18 deletions Sources/BranchSDK/BNCRequestFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,12 @@ - (void)addInstrumentationToJSON:(NSMutableDictionary *)json {
// BNCReferringURLUtility requires the endpoint string to determine which query params are applied
- (void)addReferringURLsToJSON:(NSMutableDictionary *)json forEndpoint:(NSString *)endpoint {
// Not a singleton, but BNCReferringURLUtility does pull from storage
BNCReferringURLUtility *utility = [BNCReferringURLUtility new];
NSDictionary *urlQueryParams = [utility referringURLQueryParamsForEndpoint:endpoint];
[json bnc_safeAddEntriesFromDictionary:urlQueryParams];
if ([self.preferenceHelper attributionLevel] == BranchAttributionLevelFull ||
[self.preferenceHelper attributionLevelInitialized] == false) {
BNCReferringURLUtility *utility = [BNCReferringURLUtility new];
NSDictionary *urlQueryParams = [utility referringURLQueryParamsForEndpoint:endpoint];
[json bnc_safeAddEntriesFromDictionary:urlQueryParams];
}
}

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

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

Expand All @@ -508,18 +512,28 @@ - (NSDictionary *)v2dictionary {
NSMutableDictionary *dictionary = [NSMutableDictionary new];
@synchronized (self.deviceInfo) {
[self.deviceInfo checkAdvertisingIdentifier];

BOOL disableAdNetworkCallouts = self.preferenceHelper.disableAdNetworkCallouts;
if (disableAdNetworkCallouts) {
dictionary[@"disable_ad_network_callouts"] = [NSNumber numberWithBool:disableAdNetworkCallouts];
}

if (self.preferenceHelper.isDebug) {
dictionary[@"unidentified_device"] = @(YES);
} else {
[dictionary bnc_safeSetObject:self.deviceInfo.vendorId forKey:@"idfv"];
[dictionary bnc_safeSetObject:self.deviceInfo.advertiserId forKey:@"idfa"];
BranchAttributionLevel attributionLevel = [self.preferenceHelper attributionLevel];

if (attributionLevel == BranchAttributionLevelFull ||
[self.preferenceHelper attributionLevelInitialized] == false) {
[dictionary bnc_safeSetObject:self.deviceInfo.advertiserId forKey:@"idfa"];
}

if (attributionLevel != BranchAttributionLevelNone ||
[self.preferenceHelper attributionLevelInitialized] == false) {
[dictionary bnc_safeSetObject:self.deviceInfo.vendorId forKey:@"idfv"];
}
}

[dictionary bnc_safeSetObject:self.deviceInfo.anonId forKey:@"anon_id"];
[dictionary bnc_safeSetObject:self.deviceInfo.localIPAddress forKey:@"local_ip"];

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

// Only include hardware ID fields for Full Attribution Level
if ([self.preferenceHelper attributionLevel] == BranchAttributionLevelFull) {

// hardware id information. idfa, idfv or random
NSString *hardwareId = [self.deviceInfo.hardwareId copy];
NSString *hardwareIdType = [self.deviceInfo.hardwareIdType copy];
NSNumber *isRealHardwareId = @(self.deviceInfo.isRealHardwareId);
if (hardwareId != nil && hardwareIdType != nil && isRealHardwareId != nil) {
dict[BRANCH_REQUEST_KEY_HARDWARE_ID] = hardwareId;
dict[BRANCH_REQUEST_KEY_HARDWARE_ID_TYPE] = hardwareIdType;
dict[BRANCH_REQUEST_KEY_IS_HARDWARE_ID_REAL] = isRealHardwareId;

if (hardwareId != nil && hardwareIdType != nil && isRealHardwareId != nil) {
dict[BRANCH_REQUEST_KEY_HARDWARE_ID] = hardwareId;
dict[BRANCH_REQUEST_KEY_HARDWARE_ID_TYPE] = hardwareIdType;
dict[BRANCH_REQUEST_KEY_IS_HARDWARE_ID_REAL] = isRealHardwareId;
}
[self safeSetValue:self.deviceInfo.advertiserId forKey:@"idfa" onDict:dict];
}

// idfv is duplicated in the hardware id field when idfa is unavailable
[self safeSetValue:self.deviceInfo.vendorId forKey:BRANCH_REQUEST_KEY_IOS_VENDOR_ID onDict:dict];
// idfa is only in the hardware id field
// [self safeSetValue:deviceInfo.advertiserId forKey:@"idfa" onDict:dict];

// Only include hardware ID fields for attribution levels greater than None
if ([self.preferenceHelper attributionLevel] != BranchAttributionLevelNone) {
[self safeSetValue:self.deviceInfo.vendorId forKey:BRANCH_REQUEST_KEY_IOS_VENDOR_ID onDict:dict];
}

[self safeSetValue:self.deviceInfo.anonId forKey:@"anon_id" onDict:dict];

[self safeSetValue:[self.deviceInfo localIPAddress] forKey:@"local_ip" onDict:dict];
Expand Down
1 change: 1 addition & 0 deletions Sources/BranchSDK/Branch.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
BranchAttributionLevel const BranchAttributionLevelMinimal = @"MINIMAL";
BranchAttributionLevel const BranchAttributionLevelNone = @"NONE";


#ifndef CSSearchableItemActivityIdentifier
#define CSSearchableItemActivityIdentifier @"kCSSearchableItemActivityIdentifier"
#endif
Expand Down

0 comments on commit 1e41bc3

Please sign in to comment.