From 0e8e61185b6f7a19b814b48eb7b8f33efafeb216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Da=CC=81vid=20Viniczay?= Date: Thu, 7 Jan 2021 12:01:31 +0100 Subject: [PATCH] Moved session init at download start into the synchronised block to avoid using invalidated session --- ios/RNBackgroundDownloader.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/RNBackgroundDownloader.m b/ios/RNBackgroundDownloader.m index 7fd79129..c06e423f 100644 --- a/ios/RNBackgroundDownloader.m +++ b/ios/RNBackgroundDownloader.m @@ -116,7 +116,6 @@ + (void)setCompletionHandlerWithIdentifier: (NSString *)identifier completionHan NSLog(@"[RNBackgroundDownloader] - [Error] id, url and destination must be set"); return; } - [self lazyInitSession]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]]; if (headers != nil) { @@ -126,6 +125,7 @@ + (void)setCompletionHandlerWithIdentifier: (NSString *)identifier completionHan } @synchronized (sharedLock) { + [self lazyInitSession]; NSURLSessionDownloadTask __strong *task = [urlSession downloadTaskWithRequest:request]; RNBGDTaskConfig *taskConfig = [[RNBGDTaskConfig alloc] initWithDictionary: @{@"id": identifier, @"destination": destination}];