Skip to content

Commit 73a6391

Browse files
committed
Release 3.6.0
1 parent 7a6a3d9 commit 73a6391

File tree

11 files changed

+71
-39
lines changed

11 files changed

+71
-39
lines changed

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.5.1"
3+
s.version = "3.6.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.5.1;
1977+
MARKETING_VERSION = 3.6.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.5.1;
2012+
MARKETING_VERSION = 3.6.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.5.1;
2218+
MARKETING_VERSION = 3.6.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.5.1;
2257+
MARKETING_VERSION = 3.6.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.5.1;
2294+
MARKETING_VERSION = 3.6.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.5.1;
2329+
MARKETING_VERSION = 3.6.0;
23302330
OTHER_LDFLAGS = (
23312331
"-weak_framework",
23322332
LinkPresentation,

ChangeLog.md

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

3+
v.3.6.0
4+
- Fixes intermittent issue with universal links on cold opens
5+
36
v.3.5.1
47
- Minor logging improvement
58

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.5.1";
11+
NSString * const BNC_SDK_VERSION = @"3.6.0";
1212
NSString * const BNC_LINK_URL = @"https://bnc.lt";
1313
NSString * const BNC_CDN_URL = @"https://cdn.branch.io";
1414

Sources/BranchSDK/BNCServerInterface.m

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,23 @@ - (void)postRequest:(NSDictionary *)post url:(NSString *)url retryNumber:(NSInte
6565

6666
// TODO: confirm it's ok to send full URL instead of with the domain trimmed off
6767
self.requestEndpoint = url;
68+
69+
// Drops non-linking requests when tracking is disabled
70+
if (Branch.trackingDisabled) {
71+
72+
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Tracking is disabled, checking if %@ is linking request.", url] error:nil];
73+
74+
if (![self isLinkingRelatedRequest:url postParams:post]) {
75+
[[BNCPreferenceHelper sharedInstance] clearTrackingInformation];
76+
NSError *error = [NSError branchErrorWithCode:BNCTrackingDisabledError];
77+
[[BranchLogger shared] logWarning:[NSString stringWithFormat:@"Dropping non-linking request"] error:error];
78+
if (callback) {
79+
callback(nil, error);
80+
}
81+
return;
82+
}
83+
}
84+
6885
NSURLRequest *request = [self preparePostRequest:post url:url key:key retryNumber:retryNumber];
6986

7087
[self genericHTTPRequest:request
@@ -142,21 +159,7 @@ - (void)genericHTTPRequest:(NSURLRequest *)request retryNumber:(NSInteger)retryN
142159
}
143160
};
144161

145-
// Drops non-linking requests when tracking is disabled
146-
if (Branch.trackingDisabled) {
147-
NSString *endpoint = request.URL.absoluteString;
148-
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Tracking is disabled, checking if %@ is linking request.", endpoint] error:nil];
149162

150-
if (![self isLinkingRelatedRequest:endpoint]) {
151-
[[BNCPreferenceHelper sharedInstance] clearTrackingInformation];
152-
NSError *error = [NSError branchErrorWithCode:BNCTrackingDisabledError];
153-
[[BranchLogger shared] logWarning:[NSString stringWithFormat:@"Dropping non-linking request"] error:error];
154-
if (callback) {
155-
callback(nil, error);
156-
}
157-
return;
158-
}
159-
}
160163

161164
id<BNCNetworkOperationProtocol> operation = [self.networkService networkOperationWithURLRequest:request.copy completion:completionHandler];
162165
[operation start];
@@ -172,9 +175,9 @@ - (void)genericHTTPRequest:(NSURLRequest *)request retryNumber:(NSInteger)retryN
172175
}
173176
}
174177

175-
- (BOOL)isLinkingRelatedRequest:(NSString *)endpoint {
176-
BNCPreferenceHelper *prefs = [BNCPreferenceHelper sharedInstance];
177-
BOOL hasIdentifier = (prefs.linkClickIdentifier.length > 0 ) || (prefs.spotlightIdentifier.length > 0 ) || (prefs.universalLinkUrl.length > 0);
178+
- (BOOL)isLinkingRelatedRequest:(NSString *)endpoint postParams:(NSDictionary *)post {
179+
180+
BOOL hasIdentifier = (post[BRANCH_REQUEST_KEY_LINK_IDENTIFIER] != nil ) || (post[BRANCH_REQUEST_KEY_LINK_IDENTIFIER] != nil) || (post[BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL] != nil);
178181

179182
// Allow install to resolve a link.
180183
if ([endpoint containsString:@"/v1/install"]) {

Sources/BranchSDK/BNCServerRequestQueue.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ - (instancetype)init {
4242

4343
self.queue = [NSMutableArray<BNCServerRequest *> new];
4444
self.asyncQueue = dispatch_queue_create("io.branch.persist_queue", DISPATCH_QUEUE_SERIAL);
45+
self.processArchivedOpens = YES;
4546
return self;
4647
}
4748

@@ -167,7 +168,8 @@ - (BranchOpenRequest *)findExistingInstallOrOpen {
167168
BNCServerRequest *request = [self.queue objectAtIndex:i];
168169

169170
// Install subclasses open, so only need to check open
170-
if ([request isKindOfClass:[BranchOpenRequest class]]) {
171+
// Request should not be the one added from archived queue
172+
if ([request isKindOfClass:[BranchOpenRequest class]] && !((BranchOpenRequest *)request).isFromArchivedQueue) {
171173
return (BranchOpenRequest *)request;
172174
}
173175
}
@@ -279,6 +281,11 @@ - (void)retrieve {
279281
NSData *data = [NSData dataWithContentsOfURL:self.class.URLForQueueFile options:0 error:&error];
280282
if (!error && data) {
281283
NSMutableArray *decodedQueue = [self unarchiveQueueFromData:data];
284+
for (id request in decodedQueue) {
285+
if ([request isKindOfClass:[BranchOpenRequest class]] || [request isKindOfClass:[BranchInstallRequest class]]) {
286+
((BranchOpenRequest *)request).isFromArchivedQueue = YES;
287+
}
288+
}
282289
self.queue = decodedQueue;
283290
}
284291
}

Sources/BranchSDK/Branch.m

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ + (void)setTrackingDisabled:(BOOL)disabled {
526526
// Set the flag:
527527
[BNCPreferenceHelper sharedInstance].trackingDisabled = NO;
528528
// Initialize a Branch session:
529-
[Branch.getInstance initUserSessionAndCallCallback:NO sceneIdentifier:nil urlString:nil];
529+
[Branch.getInstance initUserSessionAndCallCallback:NO sceneIdentifier:nil urlString:nil reset:NO];
530530
}
531531
}
532532
}
@@ -642,7 +642,7 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options
642642
}
643643
#endif
644644

645-
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:pushURL];
645+
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:pushURL reset:NO];
646646
}
647647

648648
- (void)setDeepLinkDebugMode:(NSDictionary *)debugParams {
@@ -693,7 +693,7 @@ - (BOOL)handleDeepLink:(NSURL *)url sceneIdentifier:(NSString *)sceneIdentifier
693693
self.preferenceHelper.externalIntentURI = pattern;
694694
self.preferenceHelper.referringURL = pattern;
695695

696-
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:nil];
696+
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:nil reset:YES];
697697
return NO;
698698
}
699699

@@ -741,7 +741,7 @@ - (BOOL)handleSchemeDeepLink_private:(NSURL*)url sceneIdentifier:(NSString *)sce
741741
self.preferenceHelper.linkClickIdentifier = params[@"link_click_id"];
742742
}
743743
}
744-
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:url.absoluteString];
744+
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:url.absoluteString reset:YES];
745745
return handled;
746746
}
747747

@@ -775,7 +775,7 @@ - (BOOL)handleUniversalDeepLink_private:(NSString*)urlString sceneIdentifier:(NS
775775
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Set universalLinkUrl and referringURL to %@", urlString] error:nil];
776776
}
777777

778-
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:urlString];
778+
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:urlString reset:YES];
779779

780780
return [Branch isBranchLink:urlString];
781781
}
@@ -815,7 +815,7 @@ - (BOOL)continueUserActivity:(NSUserActivity *)userActivity sceneIdentifier:(NSS
815815
}
816816
#endif
817817

818-
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:userActivity.webpageURL.absoluteString];
818+
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:userActivity.webpageURL.absoluteString reset:YES];
819819

820820
return spotlightIdentifier != nil;
821821
}
@@ -1716,7 +1716,7 @@ - (void)applicationDidBecomeActive {
17161716
if (!Branch.trackingDisabled && self.initializationStatus != BNCInitStatusInitialized && !installOrOpenInQueue) {
17171717
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"applicationDidBecomeActive trackingDisabled %d initializationStatus %d installOrOpenInQueue %d", Branch.trackingDisabled, self.initializationStatus, installOrOpenInQueue] error:nil];
17181718

1719-
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:nil];
1719+
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:nil reset:NO];
17201720
}
17211721
});
17221722
}
@@ -1885,6 +1885,16 @@ - (void)processNextQueueItem {
18851885
return;
18861886
}
18871887
}
1888+
1889+
if ( !(((BNCServerRequestQueue*)[BNCServerRequestQueue getInstance]).processArchivedOpens)
1890+
&& [req isKindOfClass:[BranchOpenRequest class]]
1891+
&& ((BranchOpenRequest *)req).isFromArchivedQueue){
1892+
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Removed Archived Open Request from Queue %@", [req description]] error:nil];
1893+
[self.requestQueue remove:req];
1894+
self.networkCount = 0;
1895+
[self processNextQueueItem];
1896+
return;
1897+
}
18881898

18891899
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
18901900
dispatch_async(queue, ^ {
@@ -1945,11 +1955,11 @@ - (void)notifyNativeToInit {
19451955
- (void)initSafetyCheck {
19461956
if (self.initializationStatus == BNCInitStatusUninitialized) {
19471957
[[BranchLogger shared] logDebug:@"Branch avoided an error by preemptively initializing." error:nil];
1948-
[self initUserSessionAndCallCallback:NO sceneIdentifier:nil urlString:nil];
1958+
[self initUserSessionAndCallCallback:NO sceneIdentifier:nil urlString:nil reset:NO];
19491959
}
19501960
}
19511961

1952-
- (void)initUserSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSString *)sceneIdentifier urlString:(NSString *)urlString {
1962+
- (void)initUserSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSString *)sceneIdentifier urlString:(NSString *)urlString reset:(BOOL)reset {
19531963

19541964
@synchronized (self) {
19551965
if (self.deferInitForPluginRuntime) {
@@ -1971,8 +1981,10 @@ - (void)initUserSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSStr
19711981

19721982
dispatch_async(self.isolationQueue, ^(){
19731983

1974-
// If the session is not yet initialized
1975-
if (self.initializationStatus == BNCInitStatusUninitialized) {
1984+
1985+
// If the session is not yet initialized OR
1986+
// If the session is already initialized or is initializing but we need to reset it.
1987+
if ( reset || self.initializationStatus == BNCInitStatusUninitialized) {
19761988
[self initializeSessionAndCallCallback:callCallback sceneIdentifier:sceneIdentifier urlString:urlString];
19771989
}
19781990
// If the session was initialized, but callCallback was specified, do so.

Sources/BranchSDK/BranchOpenRequest.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ - (id)initWithCallback:(callbackWithStatus)callback isInstall:(BOOL)isInstall {
4040
if ((self = [super init])) {
4141
_callback = callback;
4242
_isInstall = isInstall;
43+
_isFromArchivedQueue = NO;
4344
}
4445

4546
return self;
@@ -151,6 +152,10 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error {
151152
}
152153
}
153154
}
155+
156+
if (referringURL.length > 0) {
157+
((BNCServerRequestQueue *)[BNCServerRequestQueue getInstance]).processArchivedOpens = NO;
158+
}
154159

155160
// Clear link identifiers so they don't get reused on the next open
156161
preferenceHelper.linkClickIdentifier = nil;

Sources/BranchSDK/Private/BranchOpenRequest.h

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

1414
// URL that triggered this install or open event
1515
@property (nonatomic, copy, readwrite) NSString *urlString;
16-
16+
@property (assign, nonatomic) BOOL isFromArchivedQueue;
1717
@property (nonatomic, copy) callbackWithStatus callback;
1818

1919
+ (void) waitForOpenResponseLock;

Sources/BranchSDK/Public/BNCServerRequestQueue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
@interface BNCServerRequestQueue : NSObject
1313

14+
@property (assign, nonatomic) BOOL processArchivedOpens;
15+
1416
- (void)enqueue:(BNCServerRequest *)request;
1517
- (BNCServerRequest *)dequeue;
1618
- (BNCServerRequest *)peek;

0 commit comments

Comments
 (0)