Skip to content

Commit ebf9792

Browse files
committed
sync with 3.3.0
1 parent e3baac0 commit ebf9792

File tree

15 files changed

+137
-226
lines changed

15 files changed

+137
-226
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ - (void)tearDown {
2525

2626
- (void)testInitWithBranchKeyNil {
2727
BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:nil];
28-
NSDictionary *json = [factory dataForInstall];
28+
NSDictionary *json = [factory dataForInstallWithURLString:@"https://branch.io"];
2929
XCTAssertNotNil(json);
3030

3131
// key is omitted when nil
@@ -34,7 +34,7 @@ - (void)testInitWithBranchKeyNil {
3434

3535
- (void)testInitWithBranchKeyEmpty {
3636
BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:@""];
37-
NSDictionary *json = [factory dataForInstall];
37+
NSDictionary *json = [factory dataForInstallWithURLString:@"https://branch.io"];
3838
XCTAssertNotNil(json);
3939

4040
// empty string is allowed
@@ -43,14 +43,14 @@ - (void)testInitWithBranchKeyEmpty {
4343

4444
- (void)testInitWithBranchKey {
4545
BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:@"key_abcd"];
46-
NSDictionary *json = [factory dataForInstall];
46+
NSDictionary *json = [factory dataForInstallWithURLString:@"https://branch.io"];
4747
XCTAssertNotNil(json);
4848
XCTAssertTrue([@"key_abcd" isEqualToString:[json objectForKey:@"branch_key"]]);
4949
}
5050

5151
- (void)testDataForInstall {
5252
BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:@"key_abcd"];
53-
NSDictionary *json = [factory dataForInstall];
53+
NSDictionary *json = [factory dataForInstallWithURLString:@"https://branch.io"];
5454
XCTAssertNotNil(json);
5555

5656
XCTAssertTrue([@"key_abcd" isEqualToString:[json objectForKey:@"branch_key"]]);
@@ -64,7 +64,7 @@ - (void)testDataForInstall {
6464

6565
- (void)testDataForOpen {
6666
BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:@"key_abcd"];
67-
NSDictionary *json = [factory dataForOpen];
67+
NSDictionary *json = [factory dataForOpenWithURLString:@"https://branch.io"];
6868
XCTAssertNotNil(json);
6969

7070
XCTAssertTrue([@"key_abcd" isEqualToString:[json objectForKey:@"branch_key"]]);
@@ -182,13 +182,13 @@ - (void)testDataForEventNil {
182182

183183
- (void)testDataForShortURL {
184184
BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:@"key_abcd"];
185-
NSDictionary *json = [factory dataForInstall];
185+
NSDictionary *json = [factory dataForShortURLWithLinkDataDictionary:@{}.mutableCopy isSpotlightRequest:NO];
186186
XCTAssertNotNil(json);
187187
}
188188

189189
- (void)testDataForLATD {
190190
BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:@"key_abcd"];
191-
NSDictionary *json = [factory dataForInstall];
191+
NSDictionary *json = [factory dataForLATDWithDataDictionary:@{}.mutableCopy];
192192
XCTAssertNotNil(json);
193193
}
194194

BranchSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "BranchSDK"
3-
s.version = "3.2.0"
3+
s.version = "3.3.0"
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?

BranchSDK.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,7 +1974,7 @@
19741974
"@executable_path/Frameworks",
19751975
"@loader_path/Frameworks",
19761976
);
1977-
MARKETING_VERSION = 3.2.0;
1977+
MARKETING_VERSION = 3.3.0;
19781978
OTHER_LDFLAGS = (
19791979
"-weak_framework",
19801980
LinkPresentation,
@@ -2009,7 +2009,7 @@
20092009
"@executable_path/Frameworks",
20102010
"@loader_path/Frameworks",
20112011
);
2012-
MARKETING_VERSION = 3.2.0;
2012+
MARKETING_VERSION = 3.3.0;
20132013
OTHER_LDFLAGS = (
20142014
"-weak_framework",
20152015
LinkPresentation,
@@ -2215,7 +2215,7 @@
22152215
"@loader_path/Frameworks",
22162216
);
22172217
MACH_O_TYPE = staticlib;
2218-
MARKETING_VERSION = 3.2.0;
2218+
MARKETING_VERSION = 3.3.0;
22192219
OTHER_LDFLAGS = (
22202220
"-weak_framework",
22212221
LinkPresentation,
@@ -2254,7 +2254,7 @@
22542254
"@loader_path/Frameworks",
22552255
);
22562256
MACH_O_TYPE = staticlib;
2257-
MARKETING_VERSION = 3.2.0;
2257+
MARKETING_VERSION = 3.3.0;
22582258
OTHER_LDFLAGS = (
22592259
"-weak_framework",
22602260
LinkPresentation,
@@ -2291,7 +2291,7 @@
22912291
"@executable_path/Frameworks",
22922292
"@loader_path/Frameworks",
22932293
);
2294-
MARKETING_VERSION = 3.2.0;
2294+
MARKETING_VERSION = 3.3.0;
22952295
OTHER_LDFLAGS = (
22962296
"-weak_framework",
22972297
LinkPresentation,
@@ -2326,7 +2326,7 @@
23262326
"@executable_path/Frameworks",
23272327
"@loader_path/Frameworks",
23282328
);
2329-
MARKETING_VERSION = 3.2.0;
2329+
MARKETING_VERSION = 3.3.0;
23302330
OTHER_LDFLAGS = (
23312331
"-weak_framework",
23322332
LinkPresentation,

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
Branch iOS SDK Change Log
22

3+
v.3.3.0
4+
- SDK behavior change to fix a race condition when opening a closed app with a link. In some apps, this race condition could cause the occasional loss of link data.
5+
6+
When opening a closed app with a link, the Branch SDK will no longer attempt to merge the app open and link arrival lifecycle events. Apps will now get called on "app open" and on "link arrival", which are often very close together. If your app ignores callbacks with no link data, then this change should be transparent.
7+
38
v.3.2.0
49
- Add support for setting DMA compliance parameters.
510
- Update logging to allow a custom callback so clients may reroute Branch Logs to their logging infrastructure.

Sources/BranchSDK/BNCConfig.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "BNCConfig.h"
1010

11-
NSString * const BNC_SDK_VERSION = @"3.2.0";
11+
NSString * const BNC_SDK_VERSION = @"3.3.0";
1212
NSString * const BNC_LINK_URL = @"https://bnc.lt";
1313
NSString * const BNC_CDN_URL = @"https://cdn.branch.io";
1414

Sources/BranchSDK/BNCRequestFactory.m

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ - (BOOL)isTrackingDisabled {
7676
return Branch.trackingDisabled;
7777
}
7878

79-
- (NSDictionary *)dataForInstall {
79+
- (NSDictionary *)dataForInstallWithURLString:(NSString *)urlString {
8080
NSMutableDictionary *json = [NSMutableDictionary new];
8181

8282
// All requests
@@ -100,6 +100,10 @@ - (NSDictionary *)dataForInstall {
100100
[self addAppleReceiptSourceToJSON:json];
101101
[self addTimestampsToJSON:json];
102102

103+
if (urlString) {
104+
[self safeSetValue:urlString forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json];
105+
}
106+
103107
[self addAppleAttributionTokenToJSON:json];
104108

105109
// Install Only
@@ -116,7 +120,7 @@ - (NSDictionary *)dataForInstall {
116120
return json;
117121
}
118122

119-
- (NSDictionary *)dataForOpen {
123+
- (NSDictionary *)dataForOpenWithURLString:(NSString *)urlString {
120124
NSMutableDictionary *json = [NSMutableDictionary new];
121125

122126
// All requests
@@ -143,6 +147,10 @@ - (NSDictionary *)dataForOpen {
143147
[self addAppleReceiptSourceToJSON:json];
144148
[self addTimestampsToJSON:json];
145149

150+
if (urlString) {
151+
[self safeSetValue:urlString forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json];
152+
}
153+
146154
// Usually sent with install, but retry on open if it didn't get sent
147155
[self addAppleAttributionTokenToJSON:json];
148156

@@ -279,7 +287,6 @@ - (void)addPreferenceHelperDataToJSON:(NSMutableDictionary *)json {
279287

280288
[self safeSetValue:self.preferenceHelper.linkClickIdentifier forKey:BRANCH_REQUEST_KEY_LINK_IDENTIFIER onDict:json];
281289
[self safeSetValue:self.preferenceHelper.spotlightIdentifier forKey:BRANCH_REQUEST_KEY_SPOTLIGHT_IDENTIFIER onDict:json];
282-
[self safeSetValue:self.preferenceHelper.universalLinkUrl forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json];
283290
[self safeSetValue:self.preferenceHelper.initialReferrer forKey:BRANCH_REQUEST_KEY_INITIAL_REFERRER onDict:json];
284291

285292
// This was only on opens before, cause it can't exist on install.

Sources/BranchSDK/BNCServerRequestQueue.m

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -161,56 +161,17 @@ - (BOOL)containsInstallOrOpen {
161161
}
162162
}
163163

164-
- (BOOL)removeInstallOrOpen {
164+
- (BranchOpenRequest *)findExistingInstallOrOpen {
165165
@synchronized (self) {
166166
for (NSUInteger i = 0; i < self.queue.count; i++) {
167167
BNCServerRequest *request = [self.queue objectAtIndex:i];
168-
// Install extends open, so only need to check open.
169-
if ([request isKindOfClass:[BranchOpenRequest class]]) {
170-
[[BranchLogger shared] logDebug:@"Removing open request."];
171-
((BranchOpenRequest *)request).callback = nil;
172-
[self remove:request];
173-
return YES;
174-
}
175-
}
176-
return NO;
177-
}
178-
}
179-
180-
- (BranchOpenRequest *)moveInstallOrOpenToFront:(NSInteger)networkCount {
181-
@synchronized (self) {
182-
183-
BOOL requestAlreadyInProgress = networkCount > 0;
184168

185-
BNCServerRequest *openOrInstallRequest;
186-
for (NSUInteger i = 0; i < self.queue.count; i++) {
187-
BNCServerRequest *req = [self.queue objectAtIndex:i];
188-
if ([req isKindOfClass:[BranchOpenRequest class]]) {
189-
190-
// Already in front, nothing to do
191-
if (i == 0 || (i == 1 && requestAlreadyInProgress)) {
192-
return (BranchOpenRequest *)req;
193-
}
194-
195-
// Otherwise, pull this request out and stop early
196-
openOrInstallRequest = [self removeAt:i];
197-
break;
169+
// Install subclasses open, so only need to check open
170+
if ([request isKindOfClass:[BranchOpenRequest class]]) {
171+
return (BranchOpenRequest *)request;
198172
}
199173
}
200-
201-
if (!openOrInstallRequest) {
202-
[[BranchLogger shared] logError:@"No install or open request in queue while trying to move it to the front." error:nil];
203-
return nil;
204-
}
205-
206-
if (!requestAlreadyInProgress || !self.queue.count) {
207-
[self insert:openOrInstallRequest at:0];
208-
}
209-
else {
210-
[self insert:openOrInstallRequest at:1];
211-
}
212-
213-
return (BranchOpenRequest *)openOrInstallRequest;
174+
return nil;
214175
}
215176
}
216177

0 commit comments

Comments
 (0)