Skip to content

Commit 65041bc

Browse files
committed
Merge branch 'SDK-1067-short-link-generation-issue' into staging
# Conflicts: # Branch.xcodeproj/project.pbxproj
2 parents 01d0b5e + 6f298d0 commit 65041bc

File tree

4 files changed

+67
-3
lines changed

4 files changed

+67
-3
lines changed

Branch.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
5F78EDE4249C31FA00E313B9 /* BNCTestNetworkService.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F78EDC0249C31FA00E313B9 /* BNCTestNetworkService.m */; };
102102
5F78EDE5249C31FA00E313B9 /* BranchCommerce.Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F78EDC1249C31FA00E313B9 /* BranchCommerce.Test.m */; };
103103
5F78EDE6249C31FA00E313B9 /* BranchEvent.Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F78EDC2249C31FA00E313B9 /* BranchEvent.Test.m */; };
104+
5F790AFD252E73C000C82E83 /* BranchUserTrackingDisabled.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F790AFC252E73C000C82E83 /* BranchUserTrackingDisabled.m */; };
104105
5F7BD69D23341EB00067E5DA /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F7BD69C23341EB00067E5DA /* WebKit.framework */; };
105106
5FA313A22327107B007BAA6A /* BNCUserAgentCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FA17908232702F00012B500 /* BNCUserAgentCollector.m */; };
106107
/* End PBXBuildFile section */
@@ -232,6 +233,7 @@
232233
5F78EDC0249C31FA00E313B9 /* BNCTestNetworkService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCTestNetworkService.m; sourceTree = "<group>"; };
233234
5F78EDC1249C31FA00E313B9 /* BranchCommerce.Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchCommerce.Test.m; sourceTree = "<group>"; };
234235
5F78EDC2249C31FA00E313B9 /* BranchEvent.Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchEvent.Test.m; sourceTree = "<group>"; };
236+
5F790AFC252E73C000C82E83 /* BranchUserTrackingDisabled.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchUserTrackingDisabled.m; sourceTree = "<group>"; };
235237
5F7BD69C23341EB00067E5DA /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
236238
5FA17907232702F00012B500 /* BNCUserAgentCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCUserAgentCollector.h; sourceTree = "<group>"; };
237239
5FA17908232702F00012B500 /* BNCUserAgentCollector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCUserAgentCollector.m; sourceTree = "<group>"; };
@@ -382,6 +384,7 @@
382384
5F78ED90249C317400E313B9 /* BranchTests */ = {
383385
isa = PBXGroup;
384386
children = (
387+
5F790AFC252E73C000C82E83 /* BranchUserTrackingDisabled.m */,
385388
5F78EDB4249C31F800E313B9 /* BNCApplication.Test.m */,
386389
5F78EDAB249C31F700E313B9 /* BNCDevice.Test.m */,
387390
5F78EDB6249C31F800E313B9 /* BNCEncoder.Test.m */,
@@ -668,6 +671,7 @@
668671
5F78EDE6249C31FA00E313B9 /* BranchEvent.Test.m in Sources */,
669672
5F78EDD6249C31FA00E313B9 /* BranchMainClass.Test.m in Sources */,
670673
5F78EDC7249C31FA00E313B9 /* Branch.Test.m in Sources */,
674+
5F790AFD252E73C000C82E83 /* BranchUserTrackingDisabled.m in Sources */,
671675
5F78EDDE249C31FA00E313B9 /* BNCSettings.Test.m in Sources */,
672676
5F78EDD5249C31FA00E313B9 /* NSString+Branch.Test.m in Sources */,
673677
5F78EDD8249C31FA00E313B9 /* BNCUserAgentCollectorTests.m in Sources */,

Branch/BNCNetworkAPIService.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,13 @@ - (void) postOperationForAPIServiceName:(NSString*)serviceName
167167

168168
if (self.settings.userTrackingDisabled) {
169169
NSString *endpoint = url.path;
170-
if (([endpoint isEqualToString:@"/v1/install"] ||
171-
[endpoint isEqualToString:@"/v1/open"]) &&
170+
if ((([endpoint isEqualToString:@"/v1/install"] ||
171+
[endpoint isEqualToString:@"/v1/open"]) &&
172172
(dictionary[@"external_intent_uri"] != nil ||
173173
dictionary[@"universal_link_url"] != nil ||
174174
dictionary[@"spotlight_identitifer"] != nil ||
175-
dictionary[@"link_identifier"] != nil)) {
175+
dictionary[@"link_identifier"] != nil)) ||
176+
([endpoint isEqualToString:@"/v1/url"])) {
176177

177178
// Clear any sensitive data:
178179
dictionary[@"tracking_disabled"] = BNCWireFormatFromBool(YES);
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
/**
3+
@file BranchUserTrackingDisabled.m
4+
@package BranchTests
5+
@brief Tests creation of short link when tracking is disabled.
6+
7+
@author Nidhi Dixit
8+
@date 2020
9+
@copyright Copyright © 2020 Branch. All rights reserved.
10+
*/
11+
12+
#import <XCTest/XCTest.h>
13+
#import "BNCTestCase.h"
14+
#import "BranchError.h"
15+
#import "BNCLog.h"
16+
17+
@interface BranchUserTrackingDisabled : XCTestCase
18+
@property (strong) Branch *branch;
19+
@end
20+
21+
@implementation BranchUserTrackingDisabled
22+
23+
- (void)setUp {
24+
if (!self.branch) {
25+
self.branch = [[Branch alloc] init];
26+
[self.branch startWithConfiguration:[[BranchConfiguration alloc] initWithKey:BNCTestBranchKey]];
27+
self.branch.userTrackingDisabled = YES;
28+
}
29+
}
30+
31+
- (void)tearDown {
32+
if (self.branch)
33+
self.branch.userTrackingDisabled = NO;
34+
}
35+
36+
- (void)testShortLink {
37+
38+
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"id-123"];
39+
buo.title = @"Test link";
40+
buo.canonicalUrl = @"https://branch.io/docs/unit-tests";
41+
BranchLinkProperties *lp = [[BranchLinkProperties alloc] init];
42+
lp.channel = @"UnitTests";
43+
XCTestExpectation *expectation = [self expectationWithDescription:@"testShortLinks"];
44+
[self.branch branchShortLinkWithContent:buo linkProperties:lp completion:
45+
^ (NSURL * _Nullable shortURL, NSError * _Nullable error) {
46+
XCTAssertNil(error);
47+
XCTAssertNotNil(shortURL);
48+
XCTAssertTrue([shortURL.absoluteString hasPrefix:@"https://testbed-mac.app.link/"]);
49+
[expectation fulfill];
50+
}];
51+
[self waitForExpectationsWithTimeout:5.0 handler:nil];
52+
53+
54+
}
55+
56+
57+
@end

Examples/TestBed-macOS/TestBed-macOS.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@
489489
"$(inherited)",
490490
"@executable_path/../Frameworks",
491491
);
492+
OTHER_CODE_SIGN_FLAGS = "--deep";
492493
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.TestBed-Mac";
493494
PRODUCT_NAME = "$(TARGET_NAME)";
494495
};
@@ -506,6 +507,7 @@
506507
"$(inherited)",
507508
"@executable_path/../Frameworks",
508509
);
510+
OTHER_CODE_SIGN_FLAGS = "--deep";
509511
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.TestBed-Mac";
510512
PRODUCT_NAME = "$(TARGET_NAME)";
511513
};

0 commit comments

Comments
 (0)