Skip to content

Commit e1a21fc

Browse files
committed
SDK-1838 sync with main repo
1 parent 9b08cb2 commit e1a21fc

18 files changed

+986
-895
lines changed

Branch-TestBed/Branch-TestBed/AppDelegate.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ - (BOOL)application:(UIApplication *)application
6060

6161
[self setLogFile:@"OpenNInstall"];
6262
// [branch setIdentity:@"Bobby Branch"];
63+
6364
[branch initSessionWithLaunchOptions:launchOptions
6465
andRegisterDeepLinkHandlerUsingBranchUniversalObject:
6566
^ (BranchUniversalObject * _Nullable universalObject, BranchLinkProperties * _Nullable linkProperties, NSError * _Nullable error) {

Branch-TestBed/Branch-TestBed/LogOutputViewController.m

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,4 @@ - (void)didReceiveMemoryWarning {
2424
// Dispose of any resources that can be recreated.
2525
}
2626

27-
/*
28-
@synthesize deepLinkingCompletionDelegate;
29-
- (void)configureControlWithData:(NSDictionary *)data {
30-
NSString *message = data[@"deeplink_text"];
31-
dispatch_async(dispatch_get_main_queue(), ^{
32-
_logOutputTextView.text = message;
33-
});
34-
}*/
35-
36-
3727
@end

Branch-TestBed/Branch-TestBed/Main.storyboard

Lines changed: 441 additions & 485 deletions
Large diffs are not rendered by default.

Branch-TestBed/Branch-TestBed/ViewController.m

Lines changed: 431 additions & 349 deletions
Large diffs are not rendered by default.

Branch-TestBed/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ SPEC CHECKSUMS:
2929

3030
PODFILE CHECKSUM: 829cf437db3e2065c6c17ddea2f24b51cb0aecc0
3131

32-
COCOAPODS: 1.11.3
32+
COCOAPODS: 1.12.0

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 = "2.0.0"
3+
s.version = "2.1.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: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,7 @@
20302030
buildSettings = {
20312031
APPLICATION_EXTENSION_API_ONLY = YES;
20322032
CODE_SIGN_STYLE = Manual;
2033-
CURRENT_PROJECT_VERSION = 2.0.0;
2033+
CURRENT_PROJECT_VERSION = 2.1.0;
20342034
DEFINES_MODULE = YES;
20352035
DEVELOPMENT_TEAM = "";
20362036
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -2045,7 +2045,7 @@
20452045
"@executable_path/Frameworks",
20462046
"@loader_path/Frameworks",
20472047
);
2048-
MARKETING_VERSION = 2.0.0;
2048+
MARKETING_VERSION = 2.1.0;
20492049
PRODUCT_BUNDLE_IDENTIFIER = io.branch.BranchSDK;
20502050
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
20512051
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -2061,7 +2061,7 @@
20612061
buildSettings = {
20622062
APPLICATION_EXTENSION_API_ONLY = YES;
20632063
CODE_SIGN_STYLE = Manual;
2064-
CURRENT_PROJECT_VERSION = 2.0.0;
2064+
CURRENT_PROJECT_VERSION = 2.1.0;
20652065
DEFINES_MODULE = YES;
20662066
DEVELOPMENT_TEAM = "";
20672067
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -2076,7 +2076,7 @@
20762076
"@executable_path/Frameworks",
20772077
"@loader_path/Frameworks",
20782078
);
2079-
MARKETING_VERSION = 2.0.0;
2079+
MARKETING_VERSION = 2.1.0;
20802080
PRODUCT_BUNDLE_IDENTIFIER = io.branch.BranchSDK;
20812081
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
20822082
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -2262,7 +2262,7 @@
22622262
buildSettings = {
22632263
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
22642264
CODE_SIGN_STYLE = Manual;
2265-
CURRENT_PROJECT_VERSION = 2.0.0;
2265+
CURRENT_PROJECT_VERSION = 2.1.0;
22662266
DEFINES_MODULE = YES;
22672267
DEVELOPMENT_TEAM = "";
22682268
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -2278,7 +2278,7 @@
22782278
"@loader_path/Frameworks",
22792279
);
22802280
MACH_O_TYPE = staticlib;
2281-
MARKETING_VERSION = 2.0.0;
2281+
MARKETING_VERSION = 2.1.0;
22822282
PRODUCT_BUNDLE_IDENTIFIER = io.branch.BranchSDK;
22832283
PRODUCT_MODULE_NAME = BranchSDK;
22842284
PRODUCT_NAME = BranchSDK;
@@ -2297,7 +2297,7 @@
22972297
buildSettings = {
22982298
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
22992299
CODE_SIGN_STYLE = Manual;
2300-
CURRENT_PROJECT_VERSION = 2.0.0;
2300+
CURRENT_PROJECT_VERSION = 2.1.0;
23012301
DEFINES_MODULE = YES;
23022302
DEVELOPMENT_TEAM = "";
23032303
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -2313,7 +2313,7 @@
23132313
"@loader_path/Frameworks",
23142314
);
23152315
MACH_O_TYPE = staticlib;
2316-
MARKETING_VERSION = 2.0.0;
2316+
MARKETING_VERSION = 2.1.0;
23172317
PRODUCT_BUNDLE_IDENTIFIER = io.branch.BranchSDK;
23182318
PRODUCT_MODULE_NAME = BranchSDK;
23192319
PRODUCT_NAME = BranchSDK;
@@ -2331,7 +2331,7 @@
23312331
isa = XCBuildConfiguration;
23322332
buildSettings = {
23332333
CODE_SIGN_STYLE = Manual;
2334-
CURRENT_PROJECT_VERSION = 2.0.0;
2334+
CURRENT_PROJECT_VERSION = 2.1.0;
23352335
DEFINES_MODULE = YES;
23362336
DEVELOPMENT_TEAM = "";
23372337
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -2345,7 +2345,7 @@
23452345
"@executable_path/Frameworks",
23462346
"@loader_path/Frameworks",
23472347
);
2348-
MARKETING_VERSION = 2.0.0;
2348+
MARKETING_VERSION = 2.1.0;
23492349
PRODUCT_BUNDLE_IDENTIFIER = io.branch.BranchSDK;
23502350
PRODUCT_NAME = BranchSDK;
23512351
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -2361,7 +2361,7 @@
23612361
isa = XCBuildConfiguration;
23622362
buildSettings = {
23632363
CODE_SIGN_STYLE = Manual;
2364-
CURRENT_PROJECT_VERSION = 2.0.0;
2364+
CURRENT_PROJECT_VERSION = 2.1.0;
23652365
DEFINES_MODULE = YES;
23662366
DEVELOPMENT_TEAM = "";
23672367
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -2375,7 +2375,7 @@
23752375
"@executable_path/Frameworks",
23762376
"@loader_path/Frameworks",
23772377
);
2378-
MARKETING_VERSION = 2.0.0;
2378+
MARKETING_VERSION = 2.1.0;
23792379
PRODUCT_BUNDLE_IDENTIFIER = io.branch.BranchSDK;
23802380
PRODUCT_NAME = BranchSDK;
23812381
PROVISIONING_PROFILE_SPECIFIER = "";

BranchSDK/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 = @"2.0.0";
14+
NSString * const BNC_SDK_VERSION = @"2.1.0";

BranchSDK/Branch.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,16 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
528528
*/
529529
- (void)dispatchToIsolationQueue:(dispatch_block_t)initBlock;
530530

531+
/**
532+
DO NOT USE unless you are implementing deferred initialization for plugins.
533+
534+
Platforms such as React Native and Unity, have slow runtime startups. This results in early lifecycle events before client code can run.
535+
When `deferInitForPlugin` is true in `branch.json` initSession with cache itself until this method is called.
536+
537+
Note that while init is deferred, other calls to the Branch SDK may result in errors. For that reason, do not use this feature for general SDK init deferral.
538+
*/
539+
- (void)notifyNativeToInit;
540+
531541
#pragma mark - Push Notification support
532542

533543
/**

BranchSDK/Branch.m

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ @interface Branch() <BranchDeepLinkingControllerCompletionDelegate> {
152152

153153
@property (nonatomic, copy, nullable) void (^sceneSessionInitWithCallback)(BNCInitSessionResponse * _Nullable initResponse, NSError * _Nullable error);
154154

155+
// Support for deferred SDK initialization. Used to support slow plugin runtime startup.
156+
// This is enabled by setting deferInitForPluginRuntime to true in branch.json
157+
@property (nonatomic, assign, readwrite) BOOL deferInitForPluginRuntime;
158+
@property (nonatomic, copy, nullable) void (^cachedInitBlock)(void);
159+
155160
@end
156161

157162
@implementation Branch
@@ -226,13 +231,14 @@ - (id)initWithInterface:(BNCServerInterface *)interface
226231
[self loadUserAgent];
227232

228233
BranchJsonConfig *config = BranchJsonConfig.instance;
234+
self.deferInitForPluginRuntime = config.deferInitForPluginRuntime;
229235

230-
if (config.checkPasteboardOnInstall) {
231-
[self checkPasteboardOnInstall];
236+
if (config.enableLogging) {
237+
[self enableLogging];
232238
}
233239

234-
if (config.delayInitToCheckForSearchAds) {
235-
[self delayInitToCheckForSearchAds];
240+
if (config.checkPasteboardOnInstall) {
241+
[self checkPasteboardOnInstall];
236242
}
237243

238244
if (config.enableFacebookLinkCheck) {
@@ -613,8 +619,10 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options isReferrable:(BOOL)
613619

614620
- (void)initSceneSessionWithLaunchOptions:(NSDictionary *)options isReferrable:(BOOL)isReferrable explicitlyRequestedReferrable:(BOOL)explicitlyRequestedReferrable automaticallyDisplayController:(BOOL)automaticallyDisplayController
615621
registerDeepLinkHandler:(void (^)(BNCInitSessionResponse * _Nullable initResponse, NSError * _Nullable error))callback {
616-
self.sceneSessionInitWithCallback = callback;
617-
[self initSessionWithLaunchOptions:options isReferrable:isReferrable explicitlyRequestedReferrable:explicitlyRequestedReferrable automaticallyDisplayController:automaticallyDisplayController];
622+
[self deferInitBlock:^{
623+
self.sceneSessionInitWithCallback = callback;
624+
[self initSessionWithLaunchOptions:options isReferrable:isReferrable explicitlyRequestedReferrable:explicitlyRequestedReferrable automaticallyDisplayController:automaticallyDisplayController];
625+
}];
618626
}
619627

620628
- (void)initSessionWithLaunchOptions:(NSDictionary *)options
@@ -2136,9 +2144,36 @@ - (void)clearNetworkQueue {
21362144

21372145
#pragma mark - Session Initialization
21382146

2147+
// Defers block until notifyNativeToInit is called.
2148+
- (BOOL)deferInitBlock:(void (^)(void))block {
2149+
BOOL deferred = NO;
2150+
@synchronized (self) {
2151+
if (self.deferInitForPluginRuntime) {
2152+
self.cachedInitBlock = block;
2153+
deferred = YES;
2154+
}
2155+
}
2156+
2157+
if (!deferred && block) {
2158+
block();
2159+
}
2160+
return deferred;
2161+
}
2162+
2163+
// Releases deferred init block
2164+
- (void)notifyNativeToInit {
2165+
@synchronized (self) {
2166+
self.deferInitForPluginRuntime = NO;
2167+
}
2168+
2169+
if (self.cachedInitBlock) {
2170+
self.cachedInitBlock();
2171+
}
2172+
self.cachedInitBlock = nil;
2173+
}
2174+
21392175
// SDK-631 Workaround to maintain existing error handling behavior.
21402176
// Some methods require init before they are called. Instead of returning an error, we try to fix the situation by calling init ourselves.
2141-
// There is a follow up ticket to improve this. SDK-633
21422177
- (void)initSafetyCheck {
21432178
if (self.initializationStatus == BNCInitStatusUninitialized) {
21442179
BNCLogDebug(@"Branch avoided an error by preemptively initializing.");
@@ -2147,6 +2182,16 @@ - (void)initSafetyCheck {
21472182
}
21482183

21492184
- (void)initUserSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSString *)sceneIdentifier {
2185+
2186+
// ignore lifecycle calls while waiting for a plugin runtime.
2187+
@synchronized (self) {
2188+
if (self.deferInitForPluginRuntime) {
2189+
//NSString *debug = [NSString stringWithFormat:@"Init is deferred, ignoring call: %@", NSThread.callStackSymbols];
2190+
//BNCLogDebug(debug);
2191+
return;
2192+
}
2193+
}
2194+
21502195
dispatch_async(self.isolationQueue, ^(){
21512196
NSString *urlstring = nil;
21522197
if (self.preferenceHelper.universalLinkUrl.length) {

0 commit comments

Comments
 (0)