Skip to content

Commit 629bb36

Browse files
authored
Merge pull request #372 from BranchMetrics/retry-in-poor-network
Retry in poor network condition
2 parents 453fdcb + 91d159c commit 629bb36

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Branch-SDK/Branch-SDK/BNCServerInterface.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ - (void)genericHTTPRequest:(NSURLRequest *)request retryNumber:(NSInteger)retryN
8787
NSURLSessionCompletionHandler = ^void(NSData *data, NSURLResponse *response, NSError *error) {
8888
BNCServerResponse *serverResponse = [self processServerResponse:response data:data error:error log:log];
8989
NSInteger status = [serverResponse.statusCode integerValue];
90-
BOOL isRetryableStatusCode = status >= 500;
90+
// If the phone is in a poor network condition,
91+
// iOS will return statuses such as -1001, -1003, -1200, -9806
92+
// indicating various parts of the HTTP post failed.
93+
// We should retry in those conditions in addition to the case where the server returns a 500
94+
BOOL isRetryableStatusCode = status >= 500 || status < 0;
9195

9296
// Retry the request if appropriate
9397
if (retryNumber < self.preferenceHelper.retryCount && isRetryableStatusCode) {

0 commit comments

Comments
 (0)