2.2.2 • Published 2 years ago

@dominicvonk/react-native-apk-installer v2.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-apk-installer

Support AndroidX and Android other version

Getting started

AndroidX $ yarn add @dominicvonk/react-native-apk-installer

Mostly automatic install with react-native link (RN < 0.60)

$ react-native link @dominicvonk/react-native-apk-installer

Usage

You can use react-native-fs to download the apk file:

import RNFS from "react-native-fs";
import RNApkInstaller from "@dominicvonk/react-native-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) {
    RNApkInstaller.install(filePath);
  }
});

// Do you have permission to install from unknown sources?
RNApkInstaller.haveUnknownAppSourcesPermission();

// Turn on Unknown Sources permission settings
RNApkInstaller.showUnknownAppSourcesPermission();