Skip to content

Commit

Permalink
Merge branch 'SDK-1067-short-link-generation-issue' into staging
Browse files Browse the repository at this point in the history
# Conflicts:
#	Branch.xcodeproj/project.pbxproj
  • Loading branch information
echo-branch committed Oct 7, 2020
2 parents 01d0b5e + 6f298d0 commit 65041bc
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Branch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
5F78EDE4249C31FA00E313B9 /* BNCTestNetworkService.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F78EDC0249C31FA00E313B9 /* BNCTestNetworkService.m */; };
5F78EDE5249C31FA00E313B9 /* BranchCommerce.Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F78EDC1249C31FA00E313B9 /* BranchCommerce.Test.m */; };
5F78EDE6249C31FA00E313B9 /* BranchEvent.Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F78EDC2249C31FA00E313B9 /* BranchEvent.Test.m */; };
5F790AFD252E73C000C82E83 /* BranchUserTrackingDisabled.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F790AFC252E73C000C82E83 /* BranchUserTrackingDisabled.m */; };
5F7BD69D23341EB00067E5DA /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F7BD69C23341EB00067E5DA /* WebKit.framework */; };
5FA313A22327107B007BAA6A /* BNCUserAgentCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FA17908232702F00012B500 /* BNCUserAgentCollector.m */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -232,6 +233,7 @@
5F78EDC0249C31FA00E313B9 /* BNCTestNetworkService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCTestNetworkService.m; sourceTree = "<group>"; };
5F78EDC1249C31FA00E313B9 /* BranchCommerce.Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchCommerce.Test.m; sourceTree = "<group>"; };
5F78EDC2249C31FA00E313B9 /* BranchEvent.Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchEvent.Test.m; sourceTree = "<group>"; };
5F790AFC252E73C000C82E83 /* BranchUserTrackingDisabled.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchUserTrackingDisabled.m; sourceTree = "<group>"; };
5F7BD69C23341EB00067E5DA /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
5FA17907232702F00012B500 /* BNCUserAgentCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCUserAgentCollector.h; sourceTree = "<group>"; };
5FA17908232702F00012B500 /* BNCUserAgentCollector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCUserAgentCollector.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -382,6 +384,7 @@
5F78ED90249C317400E313B9 /* BranchTests */ = {
isa = PBXGroup;
children = (
5F790AFC252E73C000C82E83 /* BranchUserTrackingDisabled.m */,
5F78EDB4249C31F800E313B9 /* BNCApplication.Test.m */,
5F78EDAB249C31F700E313B9 /* BNCDevice.Test.m */,
5F78EDB6249C31F800E313B9 /* BNCEncoder.Test.m */,
Expand Down Expand Up @@ -668,6 +671,7 @@
5F78EDE6249C31FA00E313B9 /* BranchEvent.Test.m in Sources */,
5F78EDD6249C31FA00E313B9 /* BranchMainClass.Test.m in Sources */,
5F78EDC7249C31FA00E313B9 /* Branch.Test.m in Sources */,
5F790AFD252E73C000C82E83 /* BranchUserTrackingDisabled.m in Sources */,
5F78EDDE249C31FA00E313B9 /* BNCSettings.Test.m in Sources */,
5F78EDD5249C31FA00E313B9 /* NSString+Branch.Test.m in Sources */,
5F78EDD8249C31FA00E313B9 /* BNCUserAgentCollectorTests.m in Sources */,
Expand Down
7 changes: 4 additions & 3 deletions Branch/BNCNetworkAPIService.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ - (void) postOperationForAPIServiceName:(NSString*)serviceName

if (self.settings.userTrackingDisabled) {
NSString *endpoint = url.path;
if (([endpoint isEqualToString:@"/v1/install"] ||
[endpoint isEqualToString:@"/v1/open"]) &&
if ((([endpoint isEqualToString:@"/v1/install"] ||
[endpoint isEqualToString:@"/v1/open"]) &&
(dictionary[@"external_intent_uri"] != nil ||
dictionary[@"universal_link_url"] != nil ||
dictionary[@"spotlight_identitifer"] != nil ||
dictionary[@"link_identifier"] != nil)) {
dictionary[@"link_identifier"] != nil)) ||
([endpoint isEqualToString:@"/v1/url"])) {

// Clear any sensitive data:
dictionary[@"tracking_disabled"] = BNCWireFormatFromBool(YES);
Expand Down
57 changes: 57 additions & 0 deletions BranchTests/BranchUserTrackingDisabled.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
/**
@file BranchUserTrackingDisabled.m
@package BranchTests
@brief Tests creation of short link when tracking is disabled.
@author Nidhi Dixit
@date 2020
@copyright Copyright © 2020 Branch. All rights reserved.
*/

#import <XCTest/XCTest.h>
#import "BNCTestCase.h"
#import "BranchError.h"
#import "BNCLog.h"

@interface BranchUserTrackingDisabled : XCTestCase
@property (strong) Branch *branch;
@end

@implementation BranchUserTrackingDisabled

- (void)setUp {
if (!self.branch) {
self.branch = [[Branch alloc] init];
[self.branch startWithConfiguration:[[BranchConfiguration alloc] initWithKey:BNCTestBranchKey]];
self.branch.userTrackingDisabled = YES;
}
}

- (void)tearDown {
if (self.branch)
self.branch.userTrackingDisabled = NO;
}

- (void)testShortLink {

BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"id-123"];
buo.title = @"Test link";
buo.canonicalUrl = @"https://branch.io/docs/unit-tests";
BranchLinkProperties *lp = [[BranchLinkProperties alloc] init];
lp.channel = @"UnitTests";
XCTestExpectation *expectation = [self expectationWithDescription:@"testShortLinks"];
[self.branch branchShortLinkWithContent:buo linkProperties:lp completion:
^ (NSURL * _Nullable shortURL, NSError * _Nullable error) {
XCTAssertNil(error);
XCTAssertNotNil(shortURL);
XCTAssertTrue([shortURL.absoluteString hasPrefix:@"https://testbed-mac.app.link/"]);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5.0 handler:nil];


}


@end
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
OTHER_CODE_SIGN_FLAGS = "--deep";
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.TestBed-Mac";
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -506,6 +507,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
OTHER_CODE_SIGN_FLAGS = "--deep";
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.TestBed-Mac";
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down

0 comments on commit 65041bc

Please sign in to comment.