@@ -1905,16 +1905,8 @@ - (void) processRequest:(BNCServerRequest*)req
19051905 // Next, remove all the requests that should not be replayed. Note, we do this before
19061906 // calling callbacks, in case any of the callbacks try to kick off another request, which
19071907 // could potentially start another request (and call these callbacks again)
1908-
1909- NSSet <Class > *replayableRequests = [[NSSet alloc ] initWithArray: @[
1910- BranchEventRequest.class,
1911- BranchUserCompletedActionRequest.class,
1912- BranchSetIdentityRequest.class,
1913- BranchCommerceEventRequest.class,
1914- ]];
1915-
19161908 for (BNCServerRequest *request in requestsToFail) {
1917- if (Branch.trackingDisabled || ![replayableRequests containsObject : request.class ]) {
1909+ if (Branch.trackingDisabled || ![self isReplayableRequest : request]) {
19181910 [self .requestQueue remove: request];
19191911 }
19201912 }
@@ -1927,6 +1919,7 @@ - (void) processRequest:(BNCServerRequest*)req
19271919 BNCPerformBlockOnMainThreadSync (^ {
19281920 [request processResponse: nil error: error];
19291921
1922+ // BranchEventRequests can have callbacks directly tied to them.
19301923 if ([request isKindOfClass: [BranchEventRequest class ]]) {
19311924 [[BNCCallbackMap shared ] callCompletionForRequest: req withStatusMessage: [NSString stringWithFormat: @" Error: %@ " , error.description]];
19321925 }
@@ -1935,6 +1928,29 @@ - (void) processRequest:(BNCServerRequest*)req
19351928 }
19361929}
19371930
1931+ - (BOOL )isReplayableRequest : (BNCServerRequest *)request {
1932+
1933+ // These request types
1934+ NSSet <Class > *replayableRequests = [[NSSet alloc ] initWithArray: @[
1935+ BranchEventRequest.class,
1936+ BranchUserCompletedActionRequest.class,
1937+ BranchSetIdentityRequest.class,
1938+ BranchCommerceEventRequest.class,
1939+ ]];
1940+
1941+ if ([replayableRequests containsObject: request.class]) {
1942+
1943+ // Check if the client registered a callback for this request.
1944+ // This indicates the client will handle retry themselves, so fail it.
1945+ if ([[BNCCallbackMap shared ] containsRequest: request]) {
1946+ return NO ;
1947+ } else {
1948+ return YES ;
1949+ }
1950+ }
1951+ return NO ;
1952+ }
1953+
19381954- (void )processNextQueueItem {
19391955 dispatch_semaphore_wait (self.processing_sema , DISPATCH_TIME_FOREVER);
19401956
0 commit comments