Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS 12 stopDownload causes downloadFile promise to never resolve #568

Open
MarkEAllan opened this issue Oct 12, 2018 · 7 comments
Open

IOS 12 stopDownload causes downloadFile promise to never resolve #568

MarkEAllan opened this issue Oct 12, 2018 · 7 comments

Comments

@MarkEAllan
Copy link

I have noticed that on IOS 12 if a download started by a call to RNFS.downloadFile is cancelled by calling the RNFS.stopDownload, then the promise returned by RNFS.downloadFile is never resolved. This causes our app to never remove a modal progress screen from display.

This only happens on IOS 12. It is fine on IOS 11.4 (and lower) and Android.

I am happy to share the code if required.

@e8-XiaoMengDuan
Copy link

Any solution? I am facing same isssue.

@manjariParthiban
Copy link

manjariParthiban commented Feb 11, 2019

@XiaoMengDuan I am not sure if this is the right solution, but the following worked for me.

In the Downloader.m file,
Replace 'stopDownload' with the following,

  • (void)stopDownload
    {
    if (_task.state == NSURLSessionTaskStateRunning) {
    [_task cancel];
    // [_task cancelByProducingResumeData:^(NSData * _Nullable resumeData) {
    // if (resumeData != nil) {
    // self.resumeData = resumeData;
    // _params.resumableCallback();
    // } else {
    NSError *error = [NSError errorWithDomain:@"RNFS"
    code:@"Aborted"
    userInfo:@{
    NSLocalizedDescriptionKey: @"Download has been aborted"
    }];
    return _params.errorCallback(error);
    // }
    // }];

    }
    }

@e8-XiaoMengDuan
Copy link

@manjariParthiban Thanks for your solution.
It seems resumableCallback do not cause the rejection of downloadFile promise.
I do not need resume download, so [_task cancel] is fine.
Thanks again.

@skantus
Copy link

skantus commented Aug 11, 2019

Did you try passing the jobId as parameter? this is because all downloads contains the task id to identify what is the download in progress since simultaneous downloads are permitted.

RNFS.stopDownload(jobId)

https://github.com/itinance/react-native-fs#stopdownloadjobid-number-void

@e8-XiaoMengDuan
Copy link

I am using newest version 2.16.1 and It is working as expected on IOS 13
But I do not have any device on IOS 12 to test if this already fixed in newest version.

@newfylox
Copy link

newfylox commented Sep 1, 2020

Guys, having this issue with whatever version of this library using IOS 13.3. Any help? Is this repo still active?

@humble-programmer
Copy link

Any updates on this? This issue still very much exists. Makes the stopDownload function practically unusable on iOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants