Open Rob2k9 opened 5 years ago
same issue, did you solved it later?
I have solved this problem,but i used the downloadManager.Following is the code:
const android = RNFetchBlob.android;
const filename = 'name.apk';
const filepath = RNFetchBlob.fs.dirs.DownloadDir + '/' + filename;
const downloadAppUrl = ''http://www.moji.com/android_down.php';';// moji weather apk
RNFetchBlob.config({
addAndroidDownloads: {
useDownloadManager: true,
title: 'great, download success',
description:'an apk that will be download',
mime: 'application/vnd.android.package-archive',
// mime: 'image/jpeg',
// mediaScannable: true,
notification: true,
path: filepath
}
})
.fetch('GET', downloadAppUrl)
.then((res) => {
// console.log('res.path ', res.path());
alert('res.path ', res.path());
android.actionViewIntent(res.path(), 'application/vnd.android.package-archive');
})
.catch((err) => {
alert('download error, err is', JSON.stringify(err));
});
The difference with the official document is that i added the path optional field in the addAndroidDownloads object.When i delete the path field,the it will come into the catch code,then download the app will be wrongly.
the version of react-native i am using and the version of rn-fetch-blob are "react-native": "0.57.3", "rn-fetch-blob": "^0.10.15", and the os is macOS 10.13.6
Hi yes i solved this issue and got is working along with react-native progress circle my only issue i have now is i cant seem to cancel downloads once they have started
Hi yes i solved this issue and got is working along with react-native progress circle my only issue i have now is i cant seem to cancel downloads once they have started
I have not use the cancel download function,but as the official document says,we could use the Cancel Request after rn-fetch-blob 0.7.0.So may be you could try it. https://github.com/joltup/rn-fetch-blob#cancel-request
@Rob2k9 Could you share your code that resolve this problem ? I need a progress in my app to show user.
ok so my app was working perfect downloading with no issues at all i tried it on a firestick / nvidia shield and android TV emulator and it was working perfect one day but the next day when i opened the app to try it again the app crashes every time a download starts.
this is the version of react-native i am using and the version of rn-fetch-blob
"react-native": "0.57.8", "rn-fetch-blob": "^0.10.15"
i have tried creating a new project and adding in just the modules needed for the downloads and used a static link to an apk file i know works perfectly fine and it does work perfect for a few tries but again when the app is closed and reopened sometime later it crashes again after a download starts.
this is the code for my downloads
after attaching a debugger in android studio i have found this
the path is clearly set and even if i remove the let apk path veriable and set the path in path: still the same error :/