@@ -77,7 +77,7 @@ - (void) sendRequest:(NSDictionary * _Nullable )options bridge:(RCTBridge * _Nu
7777 if ([options valueForKey: CONFIG_TRUSTY] != nil )
7878 {
7979 NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration ];
80- session = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: self delegateQueue: taskQueue ];
80+ session = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: self delegateQueue: [ NSOperationQueue mainQueue ] ];
8181 }
8282 // the session validates SSL certification, self-signed certification will be aborted
8383 else
@@ -105,6 +105,7 @@ - (void) sendRequest:(NSDictionary * _Nullable )options bridge:(RCTBridge * _Nu
105105 callback (@[[NSNull null ], path]);
106106 // prevent memory leaks
107107 self.respData = nil ;
108+ [[UIApplication sharedApplication ] setNetworkActivityIndicatorVisible: NO ];
108109 }];
109110 [task resume ];
110111 }
@@ -127,6 +128,7 @@ - (void) sendRequest:(NSDictionary * _Nullable )options bridge:(RCTBridge * _Nu
127128 return ;
128129 }
129130 callback (@[[NSNull null ], tmpPath]);
131+ [[UIApplication sharedApplication ] setNetworkActivityIndicatorVisible: NO ];
130132 // prevent memory leaks
131133 self.respData = nil ;
132134 }];
@@ -143,9 +145,15 @@ - (void) sendRequest:(NSDictionary * _Nullable )options bridge:(RCTBridge * _Nu
143145 else {
144146 callback (@[[NSNull null ], [resp base64EncodedStringWithOptions: 0 ]]);
145147 }
148+ self.respData = nil ;
149+ [[UIApplication sharedApplication ] setNetworkActivityIndicatorVisible: NO ];
146150 }];
147151 [task resume ];
148152 }
153+
154+ // network status indicator
155+ if ([[options objectForKey: CONFIG_INDICATOR] boolValue ] == YES )
156+ [[UIApplication sharedApplication ] setNetworkActivityIndicatorVisible: YES ];
149157}
150158
151159// //////////////////////////////////////
@@ -188,6 +196,7 @@ - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dat
188196- (void ) URLSession : (NSURLSession *)session task : (NSURLSessionTask *)task didCompleteWithError : (NSError *)error {
189197 NSLog ([error localizedDescription ]);
190198 self.error = error;
199+ [[UIApplication sharedApplication ] setNetworkActivityIndicatorVisible: NO ];
191200}
192201
193202// upload progress handler
@@ -205,9 +214,9 @@ - (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didSen
205214 ];
206215}
207216
208- - (void ) application : (UIApplication *)application handleEventsForBackgroundURLSession : (NSString *)identifier completionHandler : (void (^)())completionHandler {
209-
210- }
217+ // - (void) application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)())completionHandler {
218+ //
219+ // }
211220
212221// - (void) URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session
213222// {
@@ -225,8 +234,10 @@ - (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didRec
225234{
226235 if ([options valueForKey: CONFIG_TRUSTY] != nil )
227236 completionHandler (NSURLSessionAuthChallengeUseCredential , [NSURLCredential credentialForTrust: challenge.protectionSpace.serverTrust]);
228- else
237+ else {
229238 RCTLogWarn (@" counld not create connection with an unstrusted SSL certification, if you're going to create connection anyway, add `trusty:true` to RNFetchBlob.config" );
239+ [[UIApplication sharedApplication ] setNetworkActivityIndicatorVisible: NO ];
240+ }
230241}
231242
232243@end
0 commit comments