@dominicvonk/react-native-apk-installer

A react-native library to install APK on Android

Usage no npm install needed!

<script type="module">
  import dominicvonkReactNativeApkInstaller from 'https://cdn.skypack.dev/@dominicvonk/react-native-apk-installer';
</script>

README

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();