Bläddra i källkod

Change IOS run loop strategy for better performance, related to #48

Ben Hsieh 8 år sedan
förälder
incheckning
bd92225e36
1 ändrade filer med 10 tillägg och 14 borttagningar
  1. 10
    14
      src/ios/RNFetchBlobNetwork.m

+ 10
- 14
src/ios/RNFetchBlobNetwork.m Visa fil

@@ -92,7 +92,7 @@ NSOperationQueue *taskQueue;
92 92
     
93 93
     // the session trust any SSL certification
94 94
 
95
-    NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:taskId];
95
+    NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
96 96
     session = [NSURLSession sessionWithConfiguration:defaultConfigObject delegate:self delegateQueue:[NSOperationQueue mainQueue]];
97 97
     
98 98
     if(path != nil || [self.options valueForKey:CONFIG_USE_TEMP]!= nil)
@@ -168,25 +168,21 @@ NSOperationQueue *taskQueue;
168 168
             }
169 169
      ];
170 170
     
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
-    }
184 171
 }
185 172
 
186 173
 - (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error {
187 174
     NSLog([error localizedDescription]);
188 175
     self.error = error;
189 176
     [[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
+    }
190 186
 }
191 187
 
192 188
 // upload progress handler