Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK-2309 cache link data when initialization is deferred #1369

Merged
merged 5 commits into from
Apr 3, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
// 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)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) {
echo-branch marked this conversation as resolved.
Show resolved Hide resolved
[[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;
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Using cached link: %@", urlString]];

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

View check run for this annotation

Codecov / codecov/patch

Sources/BranchSDK/Branch.m#L1937-L1938

Added lines #L1937 - L1938 were not covered by tests
}
self.cachedURLString = nil;
}
}

Expand Down
Loading