Update apk and update from app store in React Native.
JavaScript Java Objective-C
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
android Version 1.0.0 Nov 28, 2016
ios Version 1.0.0 Nov 28, 2016
.gitignore Version 1.0.0 Nov 28, 2016
.npmignore Version 1.0.0 Nov 28, 2016
LICENSE Initial commit Nov 28, 2016
README.md update Readme.md Jan 11, 2017
index.js boolean forceUpdate is read from server and notNeedUpdate func is cal… Jan 10, 2017
package.json update Readme.md Jan 11, 2017

README.md

React Native AppUpdate

Update apk and update from app store in React Native.

Installation

npm install react-native-appupdate --save

Adding automatically with react-native link

react-native link react-native-appupdate
react-native link react-native-fs

Usage

import { Alert } from 'react-native';
import AppUpdate from 'react-native-appupdate';

const appUpdate = new AppUpdate({
  iosAppId: '123456',
  apkVersionUrl: 'https://github.com/version.json',
  needUpdateApp: (needUpdate) => {
    Alert.alert(
      'Update tip',
      'Finding new version, do you want to update?',
      [
        {text: 'Cancel', onPress: () => {}},
        {text: 'Update', onPress: () => needUpdate(true)}
      ]
    );
  },
  forceUpdateApp: () => {
    console.log("Force update will start")
  },
  notNeedUpdateApp: () => {
    console.log("App is up to date")
  },
  downloadApkStart: () => { console.log("Start") },
  downloadApkProgress: (progress) => { console.log(`Downloading ${progress}%...`) },
  downloadApkEnd: () => { console.log("End") },
  onError: () => { console.log("downloadApkError") }
});
appUpdate.checkUpdate();
// version.json
{
  "versionName":"1.0.0",
  "apkUrl":"https://github.com/NewApp.apk",
  "forceUpdate": false
}

Third Library

  • react-native-fs