react-native-blob-util
react-native-blob-util copied to clipboard
ANR on Downloading PDF on Android
Getting Few ANRs on Crashlytics on download PDF
Version Used: "react": "17.0.1", "react-native": "0.64.4", "react-native-blob-util": "^0.17.0"
Code:
downloadPDF(pdfUrl, pdfName) {
const { dirs } = RNFetchBlob.fs;
const android = RNFetchBlob.android;
const iOS = RNFetchBlob.ios;
const dirToSave = Platform.OS === 'android' ? dirs.DownloadDir : dirs.DocumentDir
const configOptions = {
fileCache: true,
appendExt: 'pdf',
path: destPath,
addAndroidDownloads: {
useDownloadManager: true,
path: destPath,
notification: true,
title: pdfName + '.pdf',
description: pdfName,
mime: MIME_PDF,
mediaScannable: true,
},
};
RNFetchBlob.config(configOptions)
.fetch("GET", pdfUrl, {})
.then((res) => {
if (res) {
if (Platform.OS !== 'android' && res.data) {
RNFetchBlob.fs.writeFile(configOptions.path, res.data, "base64");
iOS.openDocument(configOptions.path);
} else {
if (res.path()) {
android.actionViewIntent(res.path(), MIME_PDF);
}
}
}
})
.catch((error) => {
//Throw Exception
});
}
Few ANR screenshots from Crashlytics:
Can anyone help here
@cw-sanjeev At least there is a version compatibility issue here.
Downgraded lib version to 0.16.4, still facing this