joltup/rn-fetch-blob

IOS release crash on pdf download

Qazafi-Dev opened this issue · 0 comments

pdf download is working of dev mode in iOS, but when I create iOS release in XCode and launch app in testflight , it crashes the app, I do not understand why?
this is my code:
const downloadPdf = async url => {
try {
const { config, fs } = RNFetchBlob;
let date = new Date();
let dirs = Platform.OS == 'ios' ? fs.dirs.DocumentDir : fs.dirs.DownloadDir;
let configfb = {
fileCache: true,
addAndroidDownloads: {
//Related to the Android only
useDownloadManager: true,
notification: true,
path: ${dirs}/test.pdf,
description: 'Pdf file Download',
},
};
const configOptions = Platform.select({
ios: {
fileCache: configfb.fileCache,
path: configfb.addAndroidDownloads.path,
appendExt: 'pdf',
},
android: configfb,
});
config(configOptions)
.fetch('GET', ${REACT_APP_API_BASE_URL}file/file?uuid=${url?.uuid}, {
Authorization: Bearer ${accessToken.token},
// 'Content-Type' : 'multipart/form-data'
})
.then(async res => {
//Showing alert after successful downloading
try {
if (Platform.OS === 'ios') {
RNFetchBlob.fs.writeFile(configfb.addAndroidDownloads.path, res.data, 'base64');
RNFetchBlob.ios.previewDocument(configfb.addAndroidDownloads.path);

          return true;
        } else {
          Alert.alert('Report Downloaded Successfully.');

          return true;
        }
      } catch (error) {
        Alert.alert('download fail');
      }
    })
    .catch(e => console.log('eeeee', e));
} catch (error) {
  console.log('download fail');
}

};