Skip to content

Commit 6f3169e

Browse files
committed
Release 1.43.1
1 parent 153a896 commit 6f3169e

17 files changed

+167
-26
lines changed

Branch-SDK/BNCConfig.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
NSString * const BNC_API_BASE_URL = @"https://api2.branch.io";
1212
NSString * const BNC_API_VERSION = @"v1";
1313
NSString * const BNC_LINK_URL = @"https://bnc.lt";
14-
NSString * const BNC_SDK_VERSION = @"1.43.0";
14+
NSString * const BNC_SDK_VERSION = @"1.43.1";

Branch-SDK/BNCServerInterface.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ - (NSMutableDictionary *)prepareParamDict:(NSDictionary *)params
456456
fullParamDict[BRANCH_REQUEST_KEY_INSTRUMENTATION] = instrumentationDictionary;
457457
}
458458
}
459-
// For DOWNSTREAM EVENTS v1/open & v2/events, include referrer_gbraid in request if available
460-
if(([self.requestEndpoint containsString:@"/v1/open"]) || ([self.requestEndpoint containsString:@"/v2/event"])){
459+
// For DOWNSTREAM EVENTS v2/events, include referrer_gbraid in request if available
460+
if([self.requestEndpoint containsString:@"/v2/event"]){
461461
NSString *ref_gbraid = self.preferenceHelper.referrerGBRAID;
462462
if ((ref_gbraid != nil) && (ref_gbraid.length > 0)) {
463463
// Check if its valid or expired

Branch-SDK/BranchConstants.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
NSString * const BRANCH_REQUEST_KEY_PARTNER_PARAMETERS = @"partner_data";
7676

7777
NSString * const BRANCH_REQUEST_METADATA_KEY_SCANTIME_WINDOW = @"skan_time_window";
78-
NSString * const BRANCH_REQUEST_KEY_REFERRER_GBRAID = @"referrer_gbraid";
78+
NSString * const BRANCH_REQUEST_KEY_REFERRER_GBRAID = @"gbraid";
7979

8080
NSString * const BRANCH_REQUEST_ENDPOINT_SET_IDENTITY = @"profile";
8181
NSString * const BRANCH_REQUEST_ENDPOINT_APP_LINK_SETTINGS = @"app-link-settings";

Branch-SDK/BranchOpenRequest.m

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,22 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error {
161161
if ([userIdentity isKindOfClass:[NSNumber class]]) {
162162
userIdentity = [userIdentity stringValue];
163163
}
164-
165-
preferenceHelper.randomizedDeviceToken = data[BRANCH_RESPONSE_KEY_RANDOMIZED_DEVICE_TOKEN];
166-
if (!preferenceHelper.randomizedDeviceToken) {
167-
// fallback to deprecated name. Fingerprinting was removed long ago, hence the name change.
168-
preferenceHelper.randomizedDeviceToken = data[@"device_fingerprint_id"];
169-
}
170164

171-
preferenceHelper.userUrl = data[BRANCH_RESPONSE_KEY_USER_URL];
165+
166+
if ([data objectForKey:BRANCH_RESPONSE_KEY_RANDOMIZED_DEVICE_TOKEN]) {
167+
preferenceHelper.randomizedDeviceToken = data[BRANCH_RESPONSE_KEY_RANDOMIZED_DEVICE_TOKEN];
168+
if (!preferenceHelper.randomizedDeviceToken) {
169+
// fallback to deprecated name. Fingerprinting was removed long ago, hence the name change.
170+
preferenceHelper.randomizedDeviceToken = data[@"device_fingerprint_id"];
171+
}
172+
}
173+
174+
if (data[BRANCH_RESPONSE_KEY_USER_URL]) {
175+
preferenceHelper.userUrl = data[BRANCH_RESPONSE_KEY_USER_URL];
176+
}
172177
preferenceHelper.userIdentity = userIdentity;
173-
preferenceHelper.sessionID = data[BRANCH_RESPONSE_KEY_SESSION_ID];
178+
if ([data objectForKey:BRANCH_RESPONSE_KEY_SESSION_ID])
179+
preferenceHelper.sessionID = data[BRANCH_RESPONSE_KEY_SESSION_ID];
174180
preferenceHelper.previousAppBuildDate = [BNCApplication currentApplication].currentBuildDate;
175181

176182

Branch-SDK/BranchSetIdentityRequest.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error {
5252
}
5353

5454
BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper sharedInstance];
55-
preferenceHelper.randomizedBundleToken = BNCStringFromWireFormat(response.data[BRANCH_RESPONSE_KEY_RANDOMIZED_BUNDLE_TOKEN]);
56-
preferenceHelper.userUrl = response.data[BRANCH_RESPONSE_KEY_USER_URL];
55+
if (response.data[BRANCH_RESPONSE_KEY_RANDOMIZED_BUNDLE_TOKEN])
56+
preferenceHelper.randomizedBundleToken = BNCStringFromWireFormat(response.data[BRANCH_RESPONSE_KEY_RANDOMIZED_BUNDLE_TOKEN]);
57+
if (response.data[BRANCH_RESPONSE_KEY_USER_URL]) {
58+
preferenceHelper.userUrl = response.data[BRANCH_RESPONSE_KEY_USER_URL];
59+
}
5760
preferenceHelper.userIdentity = self.userId;
5861
if (response.data[BRANCH_RESPONSE_KEY_SESSION_ID]) {
5962
preferenceHelper.sessionID = response.data[BRANCH_RESPONSE_KEY_SESSION_ID];

Branch-TestBed/Branch-SDK-Tests/BNCServerInterface.Test.m

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,25 @@
1010
#import "BNCTestCase.h"
1111
#import "BNCServerInterface.h"
1212
#import "BNCPreferenceHelper.h"
13+
#import "BranchConstants.h"
1314
#import <OCMock/OCMock.h>
1415
#import <OHHTTPStubs/HTTPStubs.h>
1516
#import <OHHTTPStubs/HTTPStubsResponse+JSON.h>
1617

1718
typedef void (^UrlConnectionCallback)(NSURLResponse *, NSData *, NSError *);
1819

20+
@interface BNCServerInterface()
21+
22+
// private BNCServerInterface method/properties to prepare dictionary for requests
23+
@property (copy, nonatomic) NSString *requestEndpoint;
24+
- (NSMutableDictionary *)prepareParamDict:(NSDictionary *)params
25+
key:(NSString *)key
26+
retryNumber:(NSInteger)retryNumber
27+
requestType:(NSString *)reqType;
28+
@end
29+
30+
31+
1932
@interface BNCServerInterfaceTests : BNCTestCase
2033
@end
2134

@@ -410,4 +423,48 @@ - (void)testRequestIdFromHeader {
410423
[self waitForExpectationsWithTimeout:1.0 handler:nil];
411424
}
412425

426+
- (void) testServerInterfaceDictionaryPrepForGbraid {
427+
428+
[HTTPStubs removeAllStubs];
429+
430+
BNCServerInterface *serverInterface = [[BNCServerInterface alloc] init];
431+
serverInterface.preferenceHelper = [BNCPreferenceHelper sharedInstance];
432+
serverInterface.preferenceHelper.retryCount = 3;
433+
serverInterface.requestEndpoint = @"/v2/event/standard";
434+
435+
[BNCPreferenceHelper sharedInstance].randomizedBundleToken = @"575759106028389737";
436+
437+
// Set referrerGBRAID and referrerGBRAIDInitDate
438+
NSString *gbraidValue = @"CjwKCAiA3L6PBhBvEiwAINlJ9Chixm216y8kYYJ1K94dm4FEkOgFfhIdKQdjWsYB7FqE7rf_zkGNEhoCuIEQAvD_BwE";
439+
[BNCPreferenceHelper sharedInstance].referrerGBRAID = gbraidValue;
440+
NSDate *now = [NSDate date];
441+
[BNCPreferenceHelper sharedInstance].referrerGBRAIDInitDate = now;
442+
443+
//Check - gbraid should be present
444+
NSMutableDictionary *result = [serverInterface prepareParamDict:NULL key:@"1234567890" retryNumber:3 requestType:@"POST"];
445+
XCTAssertNotNil([result objectForKey:BRANCH_REQUEST_KEY_REFERRER_GBRAID]);
446+
XCTAssertTrue([[result objectForKey:BRANCH_REQUEST_KEY_REFERRER_GBRAID] isEqualToString:gbraidValue]);
447+
448+
//Check - gbraid should not be present - endpoint is open
449+
serverInterface.requestEndpoint = @"/v1/open";
450+
result = [serverInterface prepareParamDict:NULL key:@"1234567890" retryNumber:3 requestType:@"POST"];
451+
XCTAssertNil([result objectForKey:BRANCH_REQUEST_KEY_REFERRER_GBRAID]);
452+
453+
//Check - gbraid should not be present - validity is expired
454+
NSDate *pastDate = [[NSDate date] dateByAddingTimeInterval:-2592001];
455+
[BNCPreferenceHelper sharedInstance].referrerGBRAIDInitDate = pastDate;
456+
serverInterface.requestEndpoint = @"/v2/event/standard";
457+
result = [serverInterface prepareParamDict:NULL key:@"1234567890" retryNumber:3 requestType:@"POST"];
458+
XCTAssertNil([result objectForKey:BRANCH_REQUEST_KEY_REFERRER_GBRAID]);
459+
460+
//Check - gbraid should be present. Date is reset
461+
[BNCPreferenceHelper sharedInstance].referrerGBRAIDInitDate = now;
462+
result = [serverInterface prepareParamDict:NULL key:@"1234567890" retryNumber:3 requestType:@"POST"];
463+
XCTAssertNotNil([result objectForKey:BRANCH_REQUEST_KEY_REFERRER_GBRAID]);
464+
XCTAssertTrue([[result objectForKey:BRANCH_REQUEST_KEY_REFERRER_GBRAID] isEqualToString:gbraidValue]);
465+
466+
[BNCPreferenceHelper sharedInstance].referrerGBRAID = nil;
467+
468+
}
469+
413470
@end

Branch-TestBed/Branch-SDK-Tests/BranchOpenRequestTests.m

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,4 +499,52 @@ - (void)testOpenWhenNotReferrable {
499499
[self awaitExpectations];
500500
}
501501

502+
- (void)testEmptyResponseFields {
503+
NSString * DEVICE_TOKEN = @"foo-token";
504+
NSString * USER_URL = @"http://foo";
505+
NSString * DEVELOPER_ID = @"foo";
506+
NSString * SESSION_ID = @"foo-session";
507+
NSString * IDENTITY = @"branch-id";
508+
509+
BNCServerResponse *response = [[BNCServerResponse alloc] init];
510+
response.data = @{
511+
BRANCH_RESPONSE_KEY_RANDOMIZED_DEVICE_TOKEN: DEVICE_TOKEN,
512+
BRANCH_RESPONSE_KEY_USER_URL: USER_URL,
513+
BRANCH_RESPONSE_KEY_DEVELOPER_IDENTITY: DEVELOPER_ID,
514+
BRANCH_RESPONSE_KEY_SESSION_ID: SESSION_ID,
515+
BRANCH_RESPONSE_KEY_RANDOMIZED_BUNDLE_TOKEN: IDENTITY
516+
};
517+
518+
BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper sharedInstance];
519+
520+
XCTestExpectation *openExpectation = [self expectationWithDescription:@"OpenRequest Expectation"];
521+
BranchOpenRequest *request = [[BranchOpenRequest alloc] initWithCallback:^(BOOL success, NSError *error) {
522+
XCTAssertNil(error);
523+
XCTAssertTrue(success);
524+
[self safelyFulfillExpectation:openExpectation];
525+
} isInstall:NO];
526+
527+
[request processResponse:response error:nil];
528+
529+
[self awaitExpectations];
530+
531+
XCTAssertEqualObjects(preferenceHelper.randomizedDeviceToken, DEVICE_TOKEN);
532+
XCTAssertEqualObjects(preferenceHelper.userUrl, USER_URL);
533+
XCTAssertEqualObjects(preferenceHelper.userIdentity, DEVELOPER_ID);
534+
XCTAssertEqualObjects(preferenceHelper.sessionID, SESSION_ID);
535+
XCTAssertEqualObjects(preferenceHelper.randomizedBundleToken, IDENTITY);
536+
XCTAssertNil(preferenceHelper.sessionParams);
537+
XCTAssertNil(preferenceHelper.linkClickIdentifier);
538+
XCTAssertNil(preferenceHelper.installParams);
539+
540+
// Now call processResponse with empty fields again.
541+
response.data = @{};
542+
[request processResponse:response error:nil];
543+
544+
XCTAssertNotNil(preferenceHelper.randomizedDeviceToken);
545+
XCTAssertNotNil(preferenceHelper.userUrl);
546+
XCTAssertNotNil(preferenceHelper.sessionID);
547+
XCTAssertNotNil(preferenceHelper.randomizedBundleToken);
548+
}
549+
502550
@end

Branch-TestBed/Branch-SDK-Tests/BranchSetIdentityRequestTests.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,26 @@ - (void)testErrorFollowedBySuccess {
156156
XCTAssertEqualObjects(preferenceHelper.installParams, RESPONSE_INSTALL_PARAMS);
157157
}
158158

159+
160+
- (void)testEmptyResponseFieldsAfterSetIdentity {
161+
162+
BNCServerResponse *response = [[BNCServerResponse alloc] init];
163+
BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper sharedInstance];
164+
165+
__block NSInteger callbackCount = 0;
166+
167+
BranchSetIdentityRequest *request = [[BranchSetIdentityRequest alloc] initWithUserId:IDENTITY_TEST_USER_ID callback:^(NSDictionary *params, NSError *error) {
168+
callbackCount++;
169+
XCTAssertNil(error);
170+
}];
171+
172+
response.data = @{};
173+
[request processResponse:response error:nil];
174+
175+
XCTAssertNotNil(preferenceHelper.randomizedDeviceToken);
176+
XCTAssertNotNil(preferenceHelper.userUrl);
177+
XCTAssertNotNil(preferenceHelper.sessionID);
178+
XCTAssertNotNil(preferenceHelper.randomizedBundleToken);
179+
}
180+
159181
@end
0 Bytes
Binary file not shown.

Branch.podspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Branch"
3-
s.version = "1.43.0"
3+
s.version = "1.43.1"
44
s.summary = "Create an HTTP URL for any piece of content in your app"
55
s.description = <<-DESC
66
- Want the highest possible conversions on your sharing feature?
@@ -32,5 +32,6 @@ Use the Branch SDK (branch.io) to create and power the links that point back to
3232
"Branch-SDK/BranchShareLink.{h,m}"
3333

3434
s.frameworks = 'CoreServices', 'SystemConfiguration'
35+
s.weak_framework = 'LinkPresentation'
3536
s.ios.frameworks = 'WebKit', 'iAd', 'CoreTelephony'
3637
end

0 commit comments

Comments
 (0)