@zt-mobile/react-native-android-apk-installer
v1.0.8
Published
React Native Android APK Installer with success/error handler
Downloads
2
Keywords
Readme
react-native-android-apk-installer
Getting started
$ npm install react-native-android-apk-installer --save
Mostly automatic installation
$ react-native link react-native-android-apk-installer
Usage
Android APK installer that handles user's interaction on installation dialog.
You can use react-native-fs to download the apk file:
import RNFS from 'react-native-fs'
import AndroidApkInstaller from 'react-native-android-apk-installer';
const filePath = RNFS.DocumentDirectoryPath + '/com.domain.example.apk';
const download = RNFS.downloadFile({
fromUrl: 'apk file download url',
toFile: filePath,
progress: res => {
console.log((res.bytesWritten / res.contentLength).toFixed(2));
},
progressDivider: 1
});
download.promise.then(result => {
if(result.statusCode == 200){
AndroidApkInstaller.install(filePath).then(data => {
console.log("Installation success")
})
.catch(error => {
console.log("Fail to install")
})
}
});