diff --git a/android/src/main/java/com/eko/RNBackgroundDownloaderModule.java b/android/src/main/java/com/eko/RNBackgroundDownloaderModule.java index 0c976a15..80d6ec72 100644 --- a/android/src/main/java/com/eko/RNBackgroundDownloaderModule.java +++ b/android/src/main/java/com/eko/RNBackgroundDownloaderModule.java @@ -24,6 +24,8 @@ import com.tonyodev.fetch2.Status; import com.tonyodev.fetch2core.DownloadBlock; import com.tonyodev.fetch2core.Func; +import com.tonyodev.fetch2.HttpUrlConnectionDownloader; +import com.tonyodev.fetch2core.Downloader; import org.jetbrains.annotations.NotNull; @@ -81,6 +83,8 @@ public RNBackgroundDownloaderModule(ReactApplicationContext reactContext) { FetchConfiguration fetchConfiguration = new FetchConfiguration.Builder(this.getReactApplicationContext()) .setDownloadConcurrentLimit(4) .setNamespace("RNBackgroundDownloader") + .enableRetryOnNetworkGain(true) + .setHttpDownloader(new HttpUrlConnectionDownloader(Downloader.FileDownloaderType.PARALLEL)) .build(); fetch = Fetch.Impl.getInstance(fetchConfiguration); fetch.addListener(this); @@ -232,6 +236,7 @@ public void call(Error error) { ); synchronized(sharedLock) { + lastProgressReport = new Date(); idToRequestId.put(id, request.getId()); requestIdToConfig.put(request.getId(), config); saveConfigMap(); diff --git a/ios/RNBackgroundDownloader.m b/ios/RNBackgroundDownloader.m index 7fd79129..53d0a5b7 100644 --- a/ios/RNBackgroundDownloader.m +++ b/ios/RNBackgroundDownloader.m @@ -65,6 +65,7 @@ - (id) init { NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; NSString *sessonIdentifier = [bundleIdentifier stringByAppendingString:@".backgrounddownloadtask"]; sessionConfig = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:sessonIdentifier]; + sessionConfig.HTTPMaximumConnectionsPerHost = 4; progressReports = [[NSMutableDictionary alloc] init]; lastProgressReport = [[NSDate alloc] init]; sharedLock = [NSNumber numberWithInt:1]; @@ -136,6 +137,7 @@ + (void)setCompletionHandlerWithIdentifier: (NSString *)identifier completionHan idToPercentMap[identifier] = @0.0; [task resume]; + lastProgressReport = [[NSDate alloc] init]; } }