@@ -150,6 +150,7 @@ - (void)copyAssetToFile: (NSString *)assetUrl completionHandler: (void(^)(NSStri
150150 NSString *uploadType = options[@" type" ] ?: @" raw" ;
151151 NSString *fieldName = options[@" field" ];
152152 NSString *customUploadId = options[@" customUploadId" ];
153+ NSString *appGroup = options[@" appGroup" ];
153154 NSDictionary *headers = options[@" headers" ];
154155 NSDictionary *parameters = options[@" parameters" ];
155156
@@ -158,7 +159,7 @@ - (void)copyAssetToFile: (NSString *)assetUrl completionHandler: (void(^)(NSStri
158159 if (requestUrl == nil ) {
159160 return reject (@" RN Uploader" , @" URL not compliant with RFC 2396" , nil );
160161 }
161-
162+
162163 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: requestUrl];
163164 [request setHTTPMethod: method];
164165
@@ -197,14 +198,14 @@ - (void)copyAssetToFile: (NSString *)assetUrl completionHandler: (void(^)(NSStri
197198 NSData *httpBody = [self createBodyWithBoundary: uuidStr path: fileURI parameters: parameters fieldName: fieldName];
198199 [request setHTTPBody: httpBody];
199200
200- uploadTask = [[self urlSession ] uploadTaskWithStreamedRequest: request];
201+ uploadTask = [[self urlSession: appGroup ] uploadTaskWithStreamedRequest: request];
201202 } else {
202203 if (parameters.count > 0 ) {
203204 reject (@" RN Uploader" , @" Parameters supported only in multipart type" , nil );
204205 return ;
205206 }
206207
207- uploadTask = [[self urlSession ] uploadTaskWithRequest: request fromFile: [NSURL URLWithString: fileURI]];
208+ uploadTask = [[self urlSession: appGroup ] uploadTaskWithRequest: request fromFile: [NSURL URLWithString: fileURI]];
208209 }
209210
210211 uploadTask.taskDescription = customUploadId ? customUploadId : [NSString stringWithFormat: @" %i " , thisUploadId];
@@ -266,9 +267,12 @@ - (NSData *)createBodyWithBoundary:(NSString *)boundary
266267 return httpBody;
267268}
268269
269- - (NSURLSession *)urlSession {
270+ - (NSURLSession *)urlSession : ( NSString *) groupId {
270271 if (_urlSession == nil ) {
271272 NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier: BACKGROUND_SESSION_ID];
273+ if (groupId != nil && ![groupId isEqualToString: @" " ]) {
274+ sessionConfiguration.sharedContainerIdentifier = groupId;
275+ }
272276 _urlSession = [NSURLSession sessionWithConfiguration: sessionConfiguration delegate: self delegateQueue: nil ];
273277 }
274278
0 commit comments