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

Does stopDownload() work differently on iOS and Android? #638

Closed
sebqq opened this issue Mar 11, 2019 · 1 comment
Closed

Does stopDownload() work differently on iOS and Android? #638

sebqq opened this issue Mar 11, 2019 · 1 comment

Comments

@sebqq
Copy link

sebqq commented Mar 11, 2019

stopDownload doesn't throw "error" promise on iOS while on Android, the promise continues with catch() block. Enclosing the code fragment

fetch = () => {
  // progress callback besides other things, saves the jobId into the state
  Service.download(country, this.progressCallback, this.onDownloadBegin)
    .promise.then((filepath) => {
        const data = this.prepareData(filepath);
        this.setState({data});
    })
    .catch(error => this.catchDownloadError(error));
}

 // this callback is called right after stopDownload() is called on android, but isn't called on iOS!
 catchDownloadError = error => {
    console.log(error);
 }

cancelFetching = () => {
    console.log("Stop download for jobId: ", this.state.jobId); // jobId is 1
    // this statement ends successfuly so stopDownload is called!
    if (this.state.jobId) {
      RNFS.stopDownload(this.state.jobId);
     }
  };

Is this normaI behaviour? Is download cancelled on iOS same as on Android? Do I need to move my catch() block functionality right under RNFS.stopDownload() call for iOS? Does anyone have any suggestions please? Thanks!

Edit

There is a memory leak and when stopDownload is called and after that a go back from the current screen. My progress callback is still receiving data...

@sebqq sebqq changed the title stopDownload() not working on ios Does stopDownload() works differently on iOS and Android? Mar 11, 2019
@sebqq sebqq changed the title Does stopDownload() works differently on iOS and Android? Does stopDownload() work differently on iOS and Android? Mar 11, 2019
@sebqq
Copy link
Author

sebqq commented Mar 12, 2019

It seems like i've solved the issue. At least i have no memory leaks for now :D

For anyone interested, I'm getting jobId from promise instead of progress callback

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

1 participant