Skip to content

Commit 2f5969a

Browse files
committed
Merge branch 'master' into SDK-1747-maccatalyst-skan-issue
2 parents 6d0f14c + 296e2e6 commit 2f5969a

File tree

11 files changed

+108
-49
lines changed

11 files changed

+108
-49
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 = "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) {

BranchSDK/BranchJsonConfig.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ extern NSString * _Nonnull const BranchJsonConfigBranchKeyOption;
1313
extern NSString * _Nonnull const BranchJsonConfigLiveKeyOption;
1414
extern NSString * _Nonnull const BranchJsonConfigTestKeyOption;
1515
extern NSString * _Nonnull const BranchJsonConfigUseTestInstanceOption;
16-
extern NSString * _Nonnull const BranchJsonConfigDelayInitToCheckForSearchAdsOption;
17-
extern NSString * _Nonnull const BranchJsonConfigAppleSearchAdsDebugModeOption;
18-
extern NSString * _Nonnull const BranchJsonConfigDeferInitializationForJSLoadOption;
16+
extern NSString * _Nonnull const BranchJsonConfigDeferInitForPluginRuntimeOption;
17+
extern NSString * _Nonnull const BranchJsonConfigEnableLogging;
1918
extern NSString * _Nonnull const BranchJsonConfigEnableFacebookLinkCheck;
2019
extern NSString * _Nonnull const BranchJsonConfigCheckPasteboardOnInstall;
2120

@@ -28,9 +27,8 @@ extern NSString * _Nonnull const BranchJsonConfigCheckPasteboardOnInstall;
2827
@property (nonatomic, readonly, nullable, copy) NSString *liveKey;
2928
@property (nonatomic, readonly, nullable, copy) NSString *testKey;
3029
@property (nonatomic, readonly, assign) BOOL useTestInstance;
31-
@property (nonatomic, readonly, assign) BOOL delayInitToCheckForSearchAds;
32-
@property (nonatomic, readonly, assign) BOOL appleSearchAdsDebugMode;
33-
@property (nonatomic, readonly, assign) BOOL deferInitializationForJSLoad;
30+
@property (nonatomic, readonly, assign) BOOL deferInitForPluginRuntime;
31+
@property (nonatomic, readonly, assign) BOOL enableLogging;
3432
@property (nonatomic, readonly, assign) BOOL enableFacebookLinkCheck;
3533
@property (nonatomic, readonly, assign) BOOL checkPasteboardOnInstall;
3634

BranchSDK/BranchJsonConfig.m

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
NSString * _Nonnull const BranchJsonConfigLiveKeyOption = @"liveKey";
1515
NSString * _Nonnull const BranchJsonConfigTestKeyOption = @"testKey";
1616
NSString * _Nonnull const BranchJsonConfigUseTestInstanceOption = @"useTestInstance";
17-
NSString * _Nonnull const BranchJsonConfigDelayInitToCheckForSearchAdsOption = @"delayInitToCheckForSearchAds";
18-
NSString * _Nonnull const BranchJsonConfigAppleSearchAdsDebugModeOption = @"appleSearchAdsDebugMode";
19-
NSString * _Nonnull const BranchJsonConfigDeferInitializationForJSLoadOption = @"deferInitializationForJSLoad";
17+
NSString * _Nonnull const BranchJsonConfigDeferInitForPluginRuntimeOption = @"deferInitForPluginRuntime";
18+
NSString * _Nonnull const BranchJsonConfigEnableLogging = @"enableLogging";
2019
NSString * _Nonnull const BranchJsonConfigEnableFacebookLinkCheck = @"enableFacebookLinkCheck";
2120
NSString * _Nonnull const BranchJsonConfigCheckPasteboardOnInstall = @"checkPasteboardOnInstall";
2221

@@ -73,7 +72,7 @@ - (void)loadConfigFile
7372
- (NSData *)configFileContents
7473
{
7574
if (!self.configFileURL) return nil;
76-
BNCLog([NSString stringWithFormat:@"Loading %@", self.configFileURL.pathComponents.lastObject]);
75+
BNCLogDebug([NSString stringWithFormat:@"Loading %@", self.configFileURL.pathComponents.lastObject]);
7776

7877
NSError *error;
7978
NSData *data = [NSData dataWithContentsOfURL:self.configFileURL options:0 error:&error];
@@ -99,12 +98,17 @@ - (void)findConfigFile
9998
@"branch.ios",
10099
@"branch"
101100
];
102-
101+
103102
[filesToCheck enumerateObjectsUsingBlock:^(NSString * _Nonnull file, NSUInteger idx, BOOL * _Nonnull stop) {
104103
configFileURL = [mainBundle URLForResource:file withExtension:@"json"];
105104
*stop = (configFileURL != nil);
106105
}];
107-
106+
107+
// Unity places the config at [[NSBundle mainBundle] bundlePath] + /Data/Raw/branch.json
108+
if (!configFileURL) {
109+
configFileURL = [mainBundle URLForResource:@"branch" withExtension:@"json" subdirectory:@"Data/Raw"];
110+
}
111+
108112
if (!configFileURL) {
109113
BNCLogDebug(@"No branch.json in app bundle.");
110114
return;
@@ -125,21 +129,15 @@ - (BOOL)useTestInstance
125129
return number.boolValue;
126130
}
127131

128-
- (BOOL)delayInitToCheckForSearchAds
129-
{
130-
NSNumber *number = self[BranchJsonConfigDelayInitToCheckForSearchAdsOption];
131-
return number.boolValue;
132-
}
133-
134-
- (BOOL)appleSearchAdsDebugMode
132+
- (BOOL)deferInitForPluginRuntime
135133
{
136-
NSNumber *number = self[BranchJsonConfigAppleSearchAdsDebugModeOption];
134+
NSNumber *number = self[BranchJsonConfigDeferInitForPluginRuntimeOption];
137135
return number.boolValue;
138136
}
139137

140-
- (BOOL)deferInitializationForJSLoad
138+
- (BOOL)enableLogging
141139
{
142-
NSNumber *number = self[BranchJsonConfigDeferInitializationForJSLoadOption];
140+
NSNumber *number = self[BranchJsonConfigEnableLogging];
143141
return number.boolValue;
144142
}
145143

BranchSDK/BranchPluginSupport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
1313
@interface BranchPluginSupport : NSObject
1414

1515
+ (BranchPluginSupport *)instance;
16+
1617
- (NSDictionary<NSString *, NSString *> *)deviceDescription;
1718

1819
@end

BranchSDK/BranchPluginSupport.m

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
#import "NSMutableDictionary+Branch.h"
1111
#import "BNCDeviceInfo.h"
1212
#import "BNCPreferenceHelper.h"
13-
14-
@interface BranchPluginSupport()
15-
16-
@end
13+
#import "Branch.h"
1714

1815
@implementation BranchPluginSupport
1916

@@ -26,7 +23,6 @@ + (BranchPluginSupport *)instance {
2623
return pluginSupport;
2724
}
2825

29-
3026
- (NSDictionary<NSString *, NSString *> *)deviceDescription {
3127
NSMutableDictionary<NSString *, NSString *> *dictionary = [NSMutableDictionary new];
3228
BNCDeviceInfo *deviceInfo = [BNCDeviceInfo getInstance];

ChangeLog.md

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

3+
v.2.1.0
4+
5+
Branch iOS SDK 2.1.0 contains improvements to testing and plugin support (Unity, RN, etc). Most clients will see no change.
6+
7+
- SDK-1831 - Improved branch.json support
8+
* Support for logging via `enableLogging`.
9+
* Removed old Apple Search Ads support.
10+
* Support for deferred SDK initialization. This allows improved plugin lifecycle support.
11+
- SDK-1802 - Fix tvOS warnings.
12+
- SDK-1774 - Update Branch TestBed UI.
13+
314
v.2.0.0
415

516
Branch iOS SDK 2.0.0 fixes longstanding issues with the umbrella header and project layout.

0 commit comments

Comments
 (0)