joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.8k stars 770 forks source link

android install apk #178

Open meiqi1992 opened 5 years ago

meiqi1992 commented 5 years ago

const android = RNFetchBlob.android

RNFetchBlob.config({ addAndroidDownloads : { useDownloadManager : true, title : 'awesome.apk', description : 'An APK that will be installed', mime : 'application/vnd.android.package-archive', mediaScannable : true, notification : true, } }) .fetch('GET', https://api.7q.cn:54015/up/20180907/74635b50da8bc30fce200ea053616c7b2cf64ffaed30309b803149c394628f1d.apk) .then((res) => { android.actionViewIntent(res.path(), 'application/vnd.android.package-archive') })

not work. help me! android 7.0+

Lloyd1229 commented 5 years ago

Have you solved the problem? I am also writing to download apk, can you share something?

meiqi1992 commented 5 years ago

need add path like this

RNFetchBlob.config({ addAndroidDownloads : { useDownloadManager : true, title : 'awesome.apk', description : 'An APK that will be installed', mime : 'application/vnd.android.package-archive', mediaScannable : true, notification : true, path: RNFetchBlob.fs.dirs.DownloadDir + "/fjdiatect.apk" //add } }) .fetch('GET', https://api.7q.cn:54015/up/20180907/74635b50da8bc30fce200ea053616c7b2cf64ffaed30309b803149c394628f1d.apk) .then((res) => { android.actionViewIntent(res.path(), 'application/vnd.android.package-archive') })

Lloyd1229 commented 5 years ago

Do you know how to get the download progress?

.progress((received: any, total: any) => { console.log( Math.floor(received / total * 100) + '%') }) It doesn't work

Jeijie commented 5 years ago

@meiqi1992 我安装上面的代码更改了还是报错,download manager could not resolve downloaded file path, 而且我打印了res的数据,路径不是在path中啊,

Jeijie commented 5 years ago

screenshot_2018-10-19-11-27-12

meiqi1992 commented 5 years ago

@Jeijie 你的代码贴出来看下?

Jeijie commented 5 years ago

RNFetchBlob.config({ addAndroidDownloads: { useDownloadManager: true, title: "xxx.apk", description: "downloading...", mime: "application/vnd.android.package-archive", mediaScannable: true, notification: true, path: RNFetchBlob.fs.dirs.DownloadDir + "/xxx.apk" } }) .fetch("GET", appUrl) .then(res => { console.warn("res...", res,res.path()); android.actionViewIntent( res.path(), "application/vnd.android.package-archive" ); }); };

Jeijie commented 5 years ago

现在是报另一个错 screenshot_2018-10-19-12-00-24

meiqi1992 commented 5 years ago

这个是权限问题,你看下android 还有什么权限没加

TaumuLu commented 5 years ago

Android 8+ add permission <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

Jeijie commented 5 years ago

@TaumuLu , I test in Android 7.1.1,It no works.

jamninetyfive commented 5 years ago

这个是权限问题,你看下android 还有什么权限没加

某些机型 安装会白屏 啥问题

GuoJiKaiHehe commented 5 years ago

me too, help

15561422575 commented 4 years ago

this problem had soultion ? i have a same problem

xxf1110 commented 4 years ago

i have a same problem

15561422575 commented 4 years ago

android.actionViewIntent(res.path(), 'application/vnd.android.package-archive') how to soultion this problem ?

Ashkan-Oliaie commented 4 years ago

Hey , I don't know if it's related to this issue or not , but I downloaded the apk (higher version of the app) but when I want to install it from within the app it raise error " app not installed " but when I click on the downloaded apkon the top bar dowload-manager the app will be installed without any error .... If someone can help me ,I'd appreaciate, I really need to install and update the app from within

qingkongyumian commented 3 years ago

I changed compileSdkVersion = 28 targetSdkVersion = 28 ,it workd。 but if
compileSdkVersion = 29 targetSdkVersion = 29 , it must turn on ACTION_MANAGE_UNKNOWN_APP_SOURCES,hope help someone

davidgarra commented 3 years ago

Hey , I don't know if it's related to this issue or not , but I downloaded the apk (higher version of the app) but when I want to install it from within the app it raise error " app not installed " but when I click on the downloaded apkon the top bar dowload-manager the app will be installed without any error .... If someone can help me ,I'd appreaciate, I really need to install and update the app from within

Did you find a solution to the "not installed" problem?

quangcanh2975 commented 1 year ago

Android 8+ add permission <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

Thank you! It works for my case with react native 0.62 SDK 28

felixrolando commented 1 year ago

Thanks, i use react native V. 0.69.1 and it works

thur-c commented 2 weeks ago

Not work for me, someone 2024?