Skip to content

Commit

Permalink
SDK-2309 cache link data when initialization is deferred for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
echo-branch committed Mar 27, 2024
1 parent 5cfec76 commit 6b1270b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Sources/BranchSDK/Branch.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ @interface Branch() <BranchDeepLinkingControllerCompletionDelegate> {
// This is enabled by setting deferInitForPluginRuntime to true in branch.json
@property (nonatomic, assign, readwrite) BOOL deferInitForPluginRuntime;
@property (nonatomic, copy, nullable) void (^cachedInitBlock)(void);
@property (nonatomic, copy, readwrite) NSString *cachedURLString;

@end

Expand Down Expand Up @@ -1922,11 +1923,21 @@ - (void)initSafetyCheck {

- (void)initUserSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSString *)sceneIdentifier urlString:(NSString *)urlString {

// ignore lifecycle calls while waiting for a plugin runtime.
@synchronized (self) {
if (self.deferInitForPluginRuntime) {
[[BranchLogger shared] logDebug:@"Branch init is deferred, ignoring init call."];
if (urlString) {
[[BranchLogger shared] logDebug:@"Branch init is deferred, caching link"];
self.cachedURLString = urlString;

Check warning on line 1930 in Sources/BranchSDK/Branch.m

View check run for this annotation

Codecov / codecov/patch

Sources/BranchSDK/Branch.m#L1929-L1930

Added lines #L1929 - L1930 were not covered by tests
} else {
[[BranchLogger shared] logDebug:@"Branch init is deferred, ignoring lifecycle call without a link"];

Check warning on line 1932 in Sources/BranchSDK/Branch.m

View check run for this annotation

Codecov / codecov/patch

Sources/BranchSDK/Branch.m#L1932

Added line #L1932 was not covered by tests
}
return;
} else {
if (!urlString && self.cachedURLString) {
urlString = self.cachedURLString;
self.cachedURLString = nil;
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Using cached link: %@", urlString]];

Check warning on line 1939 in Sources/BranchSDK/Branch.m

View check run for this annotation

Codecov / codecov/patch

Sources/BranchSDK/Branch.m#L1937-L1939

Added lines #L1937 - L1939 were not covered by tests
}
}
}

Expand Down

0 comments on commit 6b1270b

Please sign in to comment.