Skip to content

Commit

Permalink
Added param in function initUserSessionAndCallCallback for forced ses…
Browse files Browse the repository at this point in the history
…sion re-initialization irrespective of current SDK initializationStatus
  • Loading branch information
NidhiDixit09 committed Aug 2, 2024
1 parent ce36bbe commit d5132e4
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Sources/BranchSDK/Branch.m
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ + (void)setTrackingDisabled:(BOOL)disabled {
// Set the flag:
[BNCPreferenceHelper sharedInstance].trackingDisabled = NO;
// Initialize a Branch session:
[Branch.getInstance initUserSessionAndCallCallback:NO sceneIdentifier:nil urlString:nil];
[Branch.getInstance initUserSessionAndCallCallback:NO sceneIdentifier:nil urlString:nil reset:NO];
}
}
}
Expand Down Expand Up @@ -642,7 +642,7 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options
}
#endif

[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:pushURL];
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:pushURL reset:NO];
}

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

[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:nil];
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:nil reset:YES];
return NO;
}

Expand Down Expand Up @@ -741,7 +741,7 @@ - (BOOL)handleSchemeDeepLink_private:(NSURL*)url sceneIdentifier:(NSString *)sce
self.preferenceHelper.linkClickIdentifier = params[@"link_click_id"];
}
}
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:url.absoluteString];
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:url.absoluteString reset:YES];
return handled;
}

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

[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:urlString];
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:urlString reset:YES];

return [Branch isBranchLink:urlString];
}
Expand Down Expand Up @@ -815,7 +815,7 @@ - (BOOL)continueUserActivity:(NSUserActivity *)userActivity sceneIdentifier:(NSS
}
#endif

[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:userActivity.webpageURL.absoluteString];
[self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:userActivity.webpageURL.absoluteString reset:YES];

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

[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:nil];
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:nil reset:NO];
}
});
}
Expand Down Expand Up @@ -1889,6 +1889,7 @@ - (void)processNextQueueItem {
if ( !(((BNCServerRequestQueue*)[BNCServerRequestQueue getInstance]).processArchivedOpens)
&& [req isKindOfClass:[BranchOpenRequest class]]
&& ((BranchOpenRequest *)req).isFromArchivedQueue){
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Removed Archived Open Request from Queue %@", [req description]] error:nil];
[self.requestQueue remove:req];
self.networkCount = 0;
[self processNextQueueItem];
Expand Down Expand Up @@ -1954,11 +1955,11 @@ - (void)notifyNativeToInit {
- (void)initSafetyCheck {
if (self.initializationStatus == BNCInitStatusUninitialized) {
[[BranchLogger shared] logDebug:@"Branch avoided an error by preemptively initializing." error:nil];
[self initUserSessionAndCallCallback:NO sceneIdentifier:nil urlString:nil];
[self initUserSessionAndCallCallback:NO sceneIdentifier:nil urlString:nil reset:NO];
}
}

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

@synchronized (self) {
if (self.deferInitForPluginRuntime) {
Expand All @@ -1980,8 +1981,9 @@ - (void)initUserSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSStr

dispatch_async(self.isolationQueue, ^(){


// If the session is not yet initialized
if (self.initializationStatus == BNCInitStatusUninitialized) {
if ( reset || self.initializationStatus == BNCInitStatusUninitialized) {
[self initializeSessionAndCallCallback:callCallback sceneIdentifier:sceneIdentifier urlString:urlString];
}
// If the session was initialized, but callCallback was specified, do so.
Expand Down

0 comments on commit d5132e4

Please sign in to comment.