@dominicvonk/react-native-apk-installer
TypeScript icon, indicating that this package has built-in type declarations

2.2.2 • Public • Published

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

Package Sidebar

Install

npm i @dominicvonk/react-native-apk-installer

Weekly Downloads

11

Version

2.2.2

License

MIT

Unpacked Size

12 kB

Total Files

12

Last publish

Collaborators

  • dominicvonk