joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 772 forks source link

RNFetchBlob.ios.openDocument and RNFetchBlob.ios.previewDocument not working in release but working fine on debugging. #711

Open SyedShahbazHussain opened 3 years ago

SyedShahbazHussain commented 3 years ago

Using RNFetchBlob.ios.openDocument and RNFetchBlob.ios.previewDocument in ios, Working fine on debugging mode but not working in release. ReactNative: 0.60.5 rn-fetch-blob: 0.12.0

      const fileName = `abcFile.pdf`
      const dirs = RNFetchBlob.fs.dirs
      const path = dirs.DocumentDir+fileName;

    RNFetchBlob.fs.writeFile(path, this.state.base64, 'base64') .then((res) => {

     RNFetchBlob.ios.openDocument(path)
     // RNFetchBlob.ios.previewDocument(path)
}
edwinx29 commented 3 years ago

Try using RNFetchBlob.ios.openDocument(path) outside the writeFile Function and put them inside timeout to give it chance to refresh the process

setTimeout(() => { RNFetchBlob.fs.writeFile(path, data, 'base64'); RNFetchBlob.ios.previewDocument(path); },2000);

MEsteves22 commented 3 years ago

Hello, I am currently having the same problem. My files always have 0 Kb on iOS. Everything works fine on Android.

vdv commented 3 years ago

Hi! For ios try use cache directory for save files dirs.CacheDir and open it as RNFetchBlob.ios.openDocument(path)

teodorciuraru commented 3 years ago

I'm having the same issue using an analytics package alongside rn-fetch-blob. What currently worked was to disable CLang Optimization flags for the rn-fetch-blob in Release. Do you mind trying as well?

devinkg commented 3 years ago

Hi! For ios try use cache directory for save files dirs.CacheDir and open it as RNFetchBlob.ios.openDocument(path)

This solution worked for me too

hashkazi00 commented 2 years ago

is someone still facing this issue?

jeffngugi commented 2 years ago

Hello @hashkazi00 yes, am facing the issue. Can't find the file in simulator . When I include RNFetchBlob.ios.openDocument(path), the app crashes on download

johanwesteinde commented 2 years ago

setTimeout(() => { RNFetchBlob.fs.writeFile(path, data, 'base64'); RNFetchBlob.ios.previewDocument(path); },2000);

@edwinx29 I'm facing a similar issue. Would I want to call writeFile() once before calling it again in the timeout function (see code below) or only make the call in the timeout function?

await RNFetchBlob.fs.writeFile(path, this.state.base64, 'base64') setTimeout(() => { RNFetchBlob.fs.writeFile(path, data, 'base64'); RNFetchBlob.ios.previewDocument(path); },2000);