Skip to content

rnkit/rnkit-in-app-update

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm react-native MIT bitHound Score Downloads

InApp Update for react-native for React Native.

Support me with a Follow

Getting Started

First, cd to your RN project directory, and install RNMK through rnpm . If you don't have rnpm, you can install RNMK from npm with the command npm i -S rnkit-in-app-update and link it manually (see below).

Android

  • React Native < 0.29 (Using rnpm)

    rnpm install rnkit-in-app-update

  • React Native >= 0.29

    $npm install -S rnkit-in-app-update

    $react-native link rnkit-in-app-update

Manually

  1. JDK 7+ is required
  2. Add the following snippet to your android/settings.gradle:
include ':rnkit-in-app-update'
project(':rnkit-in-app-update').projectDir = new File(rootProject.projectDir, '../node_modules/rnkit-in-app-update/android/app')
  1. Declare the dependency in your android/app/build.gradle
dependencies {
    ...
    compile project(':rnkit-in-app-update')
}
  1. Import import io.rnkit.inappupdate.InAppUpdatePackage; and register it in your MainActivity (or equivalent, RN >= 0.32 MainApplication.java):
@Override
protected List<ReactPackage> getPackages() {
    return Arrays.asList(
            new MainReactPackage(),
            new InAppUpdatePackage()
    );
}

Finally, you're good to go, feel free to require rnkit-in-app-update in your JS files.

Have fun! 🤘

Basic Usage

Import library

import InAppUpdate from 'rnkit-in-app-update'

Contribution

Thanks

@yjfnypeu - UpdatePlugin

Api

/**
 * 获取安卓的metadata信息, 主要用于获取渠道号
 * @param {String} [required] key 对应的key
 */
async getAppMetaData(key);

/**
 * 下载Apk文件
 * @param {Object} options 下载参数
 * ------- options ---------
 * @param {String} [required] url apk 下载地址
 * @param {String} [required] version 版本号
 * @param {String} algorithm 可选(md5, etag), 当文件下载完成后会返回对应的值
 * @param {Bool} isForce 为true的情况下,会忽略网络条件和下载策略
 * @param {Bool} strategy 0默认,表示只判断当前环境,如果是wifi就下载,否则就不下载, 1表示监听wifi,如果当前是wifi就下载,如果当前不是wifi,就监听网络变化,如果在程序运行期间,切换到了wifi,就提示用户下载
 */
downloadApk(options);

/**
 * 安卓应用
 */
installApk();

/**
 * 暂停下载
 * 调用此方法, 系统会发送事件RNKitApkDownloadPause, type: manual
 */
pauseDownload();

/**
 * 继续下载
 */
downloadResume();

--------------- 新增事件回调 ------------
开始下载: RNKitApkStartDownload
下载进度: RNKitApkDownloadProgress, return params{received, total}
下载错误: RNKitApkDownloadError, return params{errorMsg}
下载被暂停了: RNKitApkDownloadPause, return params{type}, type: (manual, network)
下载完成了: RNKitApkDownloadComplete, return params{md5, etag, path, success}

Questions

Feel free to contact me or create an issue

made with ♥

Releases

No releases published

Packages

No packages published