@zt-mobile/react-native-android-apk-installer

1.0.8 • Public • Published

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")
        })
    }
});

Readme

Keywords

Package Sidebar

Install

npm i @zt-mobile/react-native-android-apk-installer

Weekly Downloads

0

Version

1.0.8

License

MIT

Unpacked Size

77.3 kB

Total Files

15

Last publish

Collaborators

  • khaiyuenzchwantech
  • kelvin6129