From 19305dce3520f51c6cff1ad9b995d4b6aff26fc8 Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Thu, 1 Aug 2024 14:46:23 -0700 Subject: [PATCH] Added property for Differentiating between archived and non-archived requests --- Sources/BranchSDK/BNCServerRequestQueue.m | 10 ++++++++-- Sources/BranchSDK/BranchOpenRequest.m | 1 + Sources/BranchSDK/Private/BranchOpenRequest.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Sources/BranchSDK/BNCServerRequestQueue.m b/Sources/BranchSDK/BNCServerRequestQueue.m index 8918e9dee..23a5775d2 100755 --- a/Sources/BranchSDK/BNCServerRequestQueue.m +++ b/Sources/BranchSDK/BNCServerRequestQueue.m @@ -167,7 +167,8 @@ - (BranchOpenRequest *)findExistingInstallOrOpen { BNCServerRequest *request = [self.queue objectAtIndex:i]; // Install subclasses open, so only need to check open - if ([request isKindOfClass:[BranchOpenRequest class]]) { + // Request should not be the one added from archived queue + if ([request isKindOfClass:[BranchOpenRequest class]] && !((BranchOpenRequest *)request).isFromArchivedQueue) { return (BranchOpenRequest *)request; } } @@ -279,6 +280,11 @@ - (void)retrieve { NSData *data = [NSData dataWithContentsOfURL:self.class.URLForQueueFile options:0 error:&error]; if (!error && data) { NSMutableArray *decodedQueue = [self unarchiveQueueFromData:data]; + for (id request in decodedQueue) { + if ([request isKindOfClass:[BranchOpenRequest class]] || [request isKindOfClass:[BranchInstallRequest class]]) { + ((BranchOpenRequest *)request).isFromArchivedQueue = YES; + } + } self.queue = decodedQueue; } } @@ -386,7 +392,7 @@ + (instancetype)getInstance { static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^ { sharedQueue = [[BNCServerRequestQueue alloc] init]; - //[sharedQueue retrieve]; + [sharedQueue retrieve]; [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Retrieved from storage: %@.", sharedQueue] error:nil]; }); return sharedQueue; diff --git a/Sources/BranchSDK/BranchOpenRequest.m b/Sources/BranchSDK/BranchOpenRequest.m index 96a6f7110..37aae9a2d 100644 --- a/Sources/BranchSDK/BranchOpenRequest.m +++ b/Sources/BranchSDK/BranchOpenRequest.m @@ -40,6 +40,7 @@ - (id)initWithCallback:(callbackWithStatus)callback isInstall:(BOOL)isInstall { if ((self = [super init])) { _callback = callback; _isInstall = isInstall; + _isFromArchivedQueue = NO; } return self; diff --git a/Sources/BranchSDK/Private/BranchOpenRequest.h b/Sources/BranchSDK/Private/BranchOpenRequest.h index 5e347a178..ec5717cd6 100644 --- a/Sources/BranchSDK/Private/BranchOpenRequest.h +++ b/Sources/BranchSDK/Private/BranchOpenRequest.h @@ -13,7 +13,7 @@ // URL that triggered this install or open event @property (nonatomic, copy, readwrite) NSString *urlString; - +@property (assign, nonatomic) BOOL isFromArchivedQueue; @property (nonatomic, copy) callbackWithStatus callback; + (void) waitForOpenResponseLock;