kesha-antonov / react-native-background-downloader

About 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.
https://www.npmjs.com/package/@kesha-antonov/react-native-background-downloader
Other
70 stars 14 forks source link

On android: progress and begin didn't return any progress #33

Open daniyalrathore14 opened 1 day ago

daniyalrathore14 commented 1 day ago

@kesha-antonov In Android: im getting the issue that im unable to get the progress of download.

download({ id: jobId, url: fileUrl, destination: saveToPath, metadata: {}, }) .begin(({ expectedBytes, headers }) => { console.log(Starting download of ${expectedBytes} bytes, headers); }) .progress(({ bytesDownloaded, bytesTotal }) => { console.log(Download progress: ${bytesDownloaded}% ${bytesTotal});

    const progress = (bytesDownloaded / bytesTotal) * 100;
    onProgress(progress);
  })
  .done(({ bytesDownloaded, bytesTotal }) => {
    console.log(bytesDownloaded, bytesTotal, "errorCodeerrorCode");

    completeHandler(jobId);
    resolve(true);
  })
  .error(({ error, errorCode }) => {
    console.log(error, "errorCodeerrorCode");

    reject(error);
  });
vokhuyetOz commented 1 day ago

it seems to be you got as same as my problem. when downloading, it got error but not send error event to JS side.

could you test this MR? https://github.com/kesha-antonov/react-native-background-downloader/pull/32

daniyalrathore14 commented 1 day ago

but in my case the progress and begin method is not even working once

but in my case the progress and begin method is not even working once