Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

How download audio files in react native iOS even after kill and relaunch the app?

$
0
0

I have a scenario in my app which is developed using React Native (0.59), I am trying to download audio files. I want to continue download even after user kills and relaunch it. I am trying with'react-native-background-downloader' package. I am download and play in simulator even after kill and relaunch the app. But not in actual device.Any suggestion would be appreciated.

Here is the code block I am using

let task = RNBackgroundDownloader.download({    id: fileName,    url: fileUrl,    destination: `${RNBackgroundDownloader.directories.documents}/${fileName}`,  }).begin((expectedBytes) => {    console.log(`Going to download ${expectedBytes} bytes!`);  }).progress((percent) => {    console.log(`Downloaded: ${percent * 100}%`);  }).done(() => {    console.log('Download is done!');  }).error((error) => {    console.log('Download canceled due to error: ', error);  });  

Here is my resume task

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

I am able to see Re-Downloaded: 99%, then I am getting error like'Re-Download canceled due to error: ', '“CFNetworkDownload_jtLLac.tmp” couldn’t be moved to “Documents” because either the former doesn’t exist, or the folder containing the latter doesn’t exist.


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>