Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Downloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ typedef void (^ProgressCallback)(NSNumber*, NSNumber*);
@property (copy) BeginCallback beginCallback; // Download has started (headers received)
@property (copy) ProgressCallback progressCallback; // Download is progressing
@property bool background; // Whether to continue download when app is in background
@property bool discretionary; // Whether the file may be downloaded at the OS's discretion (iOS only)
@property (copy) NSNumber* progressDivider;


Expand Down
1 change: 1 addition & 0 deletions Downloader.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ - (void)downloadFile:(RNFSDownloadParams*)params
if (_params.background) {
NSString *uuid = [[NSUUID UUID] UUIDString];
config = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:uuid];
config.discretionary = _params.discretionary;
} else {
config = [NSURLSessionConfiguration defaultSessionConfiguration];
}
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ type DownloadFileOptions = {
fromUrl: string; // URL to download file from
toFile: string; // Local filesystem path to save the file to
headers?: Headers; // An object of headers to be passed to the server
background?: boolean;
background?: boolean; // Continue the download in the background after the app terminates (iOS only)
discretionary?: boolean; // Allow the OS to control the timing and speed of the download to improve perceived performance (iOS only)
progressDivider?: number;
begin?: (res: DownloadBeginCallbackResult) => void;
progress?: (res: DownloadProgressCallbackResult) => void;
Expand Down
2 changes: 2 additions & 0 deletions RNFSManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ - (dispatch_queue_t)methodQueue
params.headers = headers;
NSNumber* background = options[@"background"];
params.background = [background boolValue];
NSNumber* discretionary = options[@"discretionary"];
params.discretionary = [discretionary boolValue];
NSNumber* progressDivider = options[@"progressDivider"];
params.progressDivider = progressDivider;

Expand Down