Skip to content

Commit 52d0045

Browse files
kdpadhiyarnuttalltravis
committed
README.md
Just added my own way to access app dir path because device wise its keep changing so i have made this solution. also app crashes because there is permission issue from library's AndroidManifest.xml file i have already added it to in. Co-Authored-By: nuttall <[email protected]> Co-Authored-By: Travis Vachon <[email protected]>
1 parent 3ab7ff9 commit 52d0045

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,33 @@ RNFetchBlob.config({
564564
.then(...)
565565
```
566566

567+
## React Native developers to access android device path for app bundle
568+
NativeModules.RNFetchBlob.getAppDir((error, path) => {
569+
//here path is your apps directory in mobile device
570+
RNFetchBlob
571+
.config({
572+
addAndroidDownloads : {
573+
useDownloadManager : true, // <-- this is the only thing required
574+
// Optional, override notification setting (default to true)
575+
notification : false,
576+
// Optional, but recommended since android DownloadManager will fail when
577+
// the url does not contains a file extension, by default the mime type will be text/plain
578+
mime : 'text/plain',
579+
description : 'File downloaded by download manager.'
580+
}
581+
})
582+
.fetch('GET', 'http://example.com/file/somefile')
583+
.then((resp) => {
584+
// the path of downloaded file
585+
resp.path()
586+
})
587+
})
588+
589+
In case error appears or app crash just go to
590+
AndroidMaifest.xml file and add
591+
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
592+
593+
567594
**Open Downloaded File with Intent**
568595

569596
This is a new feature added in `0.9.0` if you're going to open a file path using official [Linking](https://facebook.github.io/react-native/docs/linking.html) API that might not work as expected, also, if you're going to install an APK in `Downloads` app, that will not function too. As an alternative, you can try `actionViewIntent` API, which will send an ACTION_VIEW intent for you which uses the given `MIME` type.

0 commit comments

Comments
 (0)