From 0399294f5ef05200319419d2dc25ab5fc2f696a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20St=C3=A4rk?= Date: Thu, 16 Nov 2023 15:32:43 +0100 Subject: [PATCH] [iOS] invalidate session on upload and download success and failure --- src/ios/CordovaHttpPlugin.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ios/CordovaHttpPlugin.m b/src/ios/CordovaHttpPlugin.m index cfcb8f6d..032daaab 100644 --- a/src/ios/CordovaHttpPlugin.m +++ b/src/ios/CordovaHttpPlugin.m @@ -462,6 +462,7 @@ - (void)uploadFiles:(CDVInvokedUrlCommand*)command { CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary]; [weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; [[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity]; + [manager invalidateSessionCancelingTasks:YES]; } failure:^(NSURLSessionTask *task, NSError *error) { NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; [self handleError:dictionary withResponse:(NSHTTPURLResponse*)task.response error:error]; @@ -469,6 +470,7 @@ - (void)uploadFiles:(CDVInvokedUrlCommand*)command { CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary]; [weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; [[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity]; + [manager invalidateSessionCancelingTasks:YES]; }]; } @catch (NSException *exception) { @@ -539,6 +541,7 @@ - (void)downloadFile:(CDVInvokedUrlCommand*)command { CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary]; [weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; [[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity]; + [manager invalidateSessionCancelingTasks:YES]; return; } NSData *data = (NSData *)responseObject; @@ -549,6 +552,7 @@ - (void)downloadFile:(CDVInvokedUrlCommand*)command { CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary]; [weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; [[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity]; + [manager invalidateSessionCancelingTasks:YES]; return; } @@ -560,6 +564,7 @@ - (void)downloadFile:(CDVInvokedUrlCommand*)command { CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary]; [weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; [[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity]; + [manager invalidateSessionCancelingTasks:YES]; } failure:^(NSURLSessionTask *task, NSError *error) { NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; [self handleError:dictionary withResponse:(NSHTTPURLResponse*)task.response error:error]; @@ -568,6 +573,7 @@ - (void)downloadFile:(CDVInvokedUrlCommand*)command { CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary]; [weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; [[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity]; + [manager invalidateSessionCancelingTasks:YES]; }]; } @catch (NSException *exception) {