@@ -526,7 +526,7 @@ + (void)setTrackingDisabled:(BOOL)disabled {
526526 // Set the flag:
527527 [BNCPreferenceHelper sharedInstance ].trackingDisabled = NO ;
528528 // Initialize a Branch session:
529- [Branch.getInstance initUserSessionAndCallCallback: NO sceneIdentifier: nil urlString: nil ];
529+ [Branch.getInstance initUserSessionAndCallCallback: NO sceneIdentifier: nil urlString: nil reset: NO ];
530530 }
531531 }
532532}
@@ -642,7 +642,7 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options
642642 }
643643 #endif
644644
645- [self initUserSessionAndCallCallback: YES sceneIdentifier: nil urlString: pushURL];
645+ [self initUserSessionAndCallCallback: YES sceneIdentifier: nil urlString: pushURL reset: NO ];
646646}
647647
648648- (void )setDeepLinkDebugMode : (NSDictionary *)debugParams {
@@ -693,7 +693,7 @@ - (BOOL)handleDeepLink:(NSURL *)url sceneIdentifier:(NSString *)sceneIdentifier
693693 self.preferenceHelper .externalIntentURI = pattern;
694694 self.preferenceHelper .referringURL = pattern;
695695
696- [self initUserSessionAndCallCallback: YES sceneIdentifier: sceneIdentifier urlString: nil ];
696+ [self initUserSessionAndCallCallback: YES sceneIdentifier: sceneIdentifier urlString: nil reset: YES ];
697697 return NO ;
698698 }
699699
@@ -741,7 +741,7 @@ - (BOOL)handleSchemeDeepLink_private:(NSURL*)url sceneIdentifier:(NSString *)sce
741741 self.preferenceHelper .linkClickIdentifier = params[@" link_click_id" ];
742742 }
743743 }
744- [self initUserSessionAndCallCallback: YES sceneIdentifier: sceneIdentifier urlString: url.absoluteString];
744+ [self initUserSessionAndCallCallback: YES sceneIdentifier: sceneIdentifier urlString: url.absoluteString reset: YES ];
745745 return handled;
746746}
747747
@@ -775,7 +775,7 @@ - (BOOL)handleUniversalDeepLink_private:(NSString*)urlString sceneIdentifier:(NS
775775 [[BranchLogger shared ] logVerbose: [NSString stringWithFormat: @" Set universalLinkUrl and referringURL to %@ " , urlString] error: nil ];
776776 }
777777
778- [self initUserSessionAndCallCallback: YES sceneIdentifier: sceneIdentifier urlString: urlString];
778+ [self initUserSessionAndCallCallback: YES sceneIdentifier: sceneIdentifier urlString: urlString reset: YES ];
779779
780780 return [Branch isBranchLink: urlString];
781781}
@@ -815,7 +815,7 @@ - (BOOL)continueUserActivity:(NSUserActivity *)userActivity sceneIdentifier:(NSS
815815 }
816816 #endif
817817
818- [self initUserSessionAndCallCallback: YES sceneIdentifier: sceneIdentifier urlString: userActivity.webpageURL.absoluteString];
818+ [self initUserSessionAndCallCallback: YES sceneIdentifier: sceneIdentifier urlString: userActivity.webpageURL.absoluteString reset: YES ];
819819
820820 return spotlightIdentifier != nil ;
821821}
@@ -1716,7 +1716,7 @@ - (void)applicationDidBecomeActive {
17161716 if (!Branch.trackingDisabled && self.initializationStatus != BNCInitStatusInitialized && !installOrOpenInQueue) {
17171717 [[BranchLogger shared ] logVerbose: [NSString stringWithFormat: @" applicationDidBecomeActive trackingDisabled %d initializationStatus %d installOrOpenInQueue %d " , Branch.trackingDisabled, self .initializationStatus, installOrOpenInQueue] error: nil ];
17181718
1719- [self initUserSessionAndCallCallback: YES sceneIdentifier: nil urlString: nil ];
1719+ [self initUserSessionAndCallCallback: YES sceneIdentifier: nil urlString: nil reset: NO ];
17201720 }
17211721 });
17221722}
@@ -1885,6 +1885,16 @@ - (void)processNextQueueItem {
18851885 return ;
18861886 }
18871887 }
1888+
1889+ if ( !(((BNCServerRequestQueue*)[BNCServerRequestQueue getInstance ]).processArchivedOpens )
1890+ && [req isKindOfClass: [BranchOpenRequest class ]]
1891+ && ((BranchOpenRequest *)req).isFromArchivedQueue ){
1892+ [[BranchLogger shared ] logVerbose: [NSString stringWithFormat: @" Removed Archived Open Request from Queue %@ " , [req description ]] error: nil ];
1893+ [self .requestQueue remove: req];
1894+ self.networkCount = 0 ;
1895+ [self processNextQueueItem ];
1896+ return ;
1897+ }
18881898
18891899 dispatch_queue_t queue = dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 );
18901900 dispatch_async (queue, ^ {
@@ -1945,11 +1955,11 @@ - (void)notifyNativeToInit {
19451955- (void )initSafetyCheck {
19461956 if (self.initializationStatus == BNCInitStatusUninitialized) {
19471957 [[BranchLogger shared ] logDebug: @" Branch avoided an error by preemptively initializing." error: nil ];
1948- [self initUserSessionAndCallCallback: NO sceneIdentifier: nil urlString: nil ];
1958+ [self initUserSessionAndCallCallback: NO sceneIdentifier: nil urlString: nil reset: NO ];
19491959 }
19501960}
19511961
1952- - (void )initUserSessionAndCallCallback : (BOOL )callCallback sceneIdentifier : (NSString *)sceneIdentifier urlString : (NSString *)urlString {
1962+ - (void )initUserSessionAndCallCallback : (BOOL )callCallback sceneIdentifier : (NSString *)sceneIdentifier urlString : (NSString *)urlString reset : ( BOOL ) reset {
19531963
19541964 @synchronized (self) {
19551965 if (self.deferInitForPluginRuntime ) {
@@ -1971,8 +1981,10 @@ - (void)initUserSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSStr
19711981
19721982 dispatch_async (self.isolationQueue , ^(){
19731983
1974- // If the session is not yet initialized
1975- if (self.initializationStatus == BNCInitStatusUninitialized) {
1984+
1985+ // If the session is not yet initialized OR
1986+ // If the session is already initialized or is initializing but we need to reset it.
1987+ if ( reset || self.initializationStatus == BNCInitStatusUninitialized) {
19761988 [self initializeSessionAndCallCallback: callCallback sceneIdentifier: sceneIdentifier urlString: urlString];
19771989 }
19781990 // If the session was initialized, but callCallback was specified, do so.
0 commit comments