Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit bd92225

Browse files
committed
Change IOS run loop strategy for better performance, related to #48
1 parent 381f2f7 commit bd92225

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/ios/RNFetchBlobNetwork.m

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ - (void) sendRequest:(NSDictionary * _Nullable )options
9292

9393
// the session trust any SSL certification
9494

95-
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:taskId];
95+
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
9696
session = [NSURLSession sessionWithConfiguration:defaultConfigObject delegate:self delegateQueue:[NSOperationQueue mainQueue]];
9797

9898
if(path != nil || [self.options valueForKey:CONFIG_USE_TEMP]!= nil)
@@ -168,25 +168,21 @@ - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dat
168168
}
169169
];
170170

171-
if(receivedBytes >= expectedBytes)
172-
{
173-
if(respFile == YES)
174-
{
175-
[writeStream close];
176-
callback(@[[NSNull null], destPath]);
177-
}
178-
// base64 response
179-
else {
180-
callback(@[[NSNull null], [respData base64EncodedStringWithOptions:0]]);
181-
}
182-
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
183-
}
184171
}
185172

186173
- (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error {
187174
NSLog([error localizedDescription]);
188175
self.error = error;
189176
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
177+
if(respFile == YES)
178+
{
179+
[writeStream close];
180+
callback(@[error == nil ? [NSNull null] : [error localizedDescription], destPath]);
181+
}
182+
// base64 response
183+
else {
184+
callback(@[error == nil ? [NSNull null] : [error localizedDescription], [respData base64EncodedStringWithOptions:0]]);
185+
}
190186
}
191187

192188
// upload progress handler

0 commit comments

Comments
 (0)