EkoLabs / react-native-background-downloader

A library for React-Native to help you download large files on iOS and Android both in the foreground and most importantly in the background.
Other
278 stars 123 forks source link

ios error No such file or directory #65

Open amirrezamahyari opened 4 years ago

amirrezamahyari commented 4 years ago

Hi in ios when i fully close app from multi task manager and go back to app and run checkForExistingDownloads function i get error , on android with same code every thing is fine and file continued to download.

let lostTasks = await RNBackgroundDownloader.checkForExistingDownloads();
    console.log(lostTasks);
        for (let task of lostTasks) {
      task.progress((percent: any) => {
      console.log(`Downloaded: ${percent * 100}%`);
    }).done(() => {
       console.log('Downlaod is done!');
    })
      .error((error: any) => {
      console.log('Download canceled due to error: ', error);
    });
    }

i get this error : Download canceled due to error: The operation couldn’t be completed. No such file or directory and returned task from "checkForExistingDownloads" is:

{
state: "FAILED"
percent: 0
bytesWritten: 0
totalBytes: 104857600
id: "life365"
}

Have you followed the required steps before opening a bug report?

Environment

Environment: React: 16.9.0 React native: 0.61.4 react-native-background-downloader: 2.3.4

Steps to Reproduce

on ios 1.start download

  1. close app from multi tasking 3.start app again and run checkForExistingDownloads

Thanks

giuseppe4 commented 4 years ago

I confirm I can reproduce the same behavior, did you find a solution?

amirrezamahyari commented 4 years ago

@giuseppe4 not yet :(

amirrezamahyari commented 4 years ago

@ptelad can you help me in to solve problem ?

edferreira commented 4 years ago

It also happens to me. I'm able to make android downloads restart normally, but on iOS it displays an "file not found" error.

adamrhunter commented 4 years ago

I believe this is expected behaviour - If the user terminates the app, background downloads are cancelled. See Apple docs

samclewlowand commented 4 years ago

Old thread, but if you want to test what happens to the download after the app is closed, you can either terminate the app through the Xcode stop button, or add an additional button to the iOS code that calls exit(0);

The system will treat either of the above as a non-user initiated killing of the app and continue with the background download