In this repo you will find quick snippet for downloading file in React Native (android & iOS)

Install rn-fetch-blob in your project
npm i rn-fetch-blob yarn add rn-fetch-blobAdd required permission in AndroidManifest.xml
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />No changes required for iOS.
Copy DownloadFileServices.ts File into your project & import like below.
// import File in your code 👇
import { DownloadFile } from "../DownloadFileServices";
function App() {
return (
<TouchableOpacity
onPress={() => {
let fileUrl = "Your File URL";
DownloadFile(fileUrl); // Pass URL in function
}}
>
<Text>Click Me</Text>
</TouchableOpacity>
);
}Clone the project
git clone https://github.com/girish54321/ReactNativeDownloadDemo.gitGo to the project directory
cd ReactNativeDownloadDemoInstall dependencies
yarnStart the project
yarn android_dev_debugJust rename DownloadFileServices.ts to DownloadFileServices.js and remove types. 😇
Contributions are always welcome!