react-native-easy-upgrade
                                
                                 react-native-easy-upgrade copied to clipboard
                                
                                    react-native-easy-upgrade copied to clipboard
                            
                            
                            
                        Easy to upgrade your react-native app
react-native-easy-upgrade
Easy to upgrade your react-native app
Getting started
$ npm install react-native-easy-upgrade --save
Mostly automatic installation
$ react-native link react-native-easy-upgrade
Manual installation
iOS
- In XCode, in the project navigator, right click Libraries➜Add Files to [your project's name]
- Go to node_modules➜react-native-easy-upgradeand addRNEasyUpgrade.xcodeproj
- In XCode, in the project navigator, select your project. Add libRNEasyUpgrade.ato your project'sBuild Phases➜Link Binary With Libraries
- Run your project (Cmd+R)<
Android
- Open up android/app/src/main/java/[...]/MainActivity.java
- Add import org.hstar.reactnative.easyupgrade.RNEasyUpgradePackage;to the imports at the top of the file
- Add new RNEasyUpgradePackage()to the list returned by thegetPackages()method
- Append the following lines to android/settings.gradle:
include ':react-native-easy-upgrade'
project(':react-native-easy-upgrade').projectDir = new File(rootProject.projectDir,   '../node_modules/react-native-easy-upgrade/android')
- Insert the following lines inside the dependencies block in android/app/build.gradle:
  implementation project(':react-native-easy-upgrade')
2019-8-30 Note:
This project has been added to the android file provider, if the main project or other plug-in provider conflicts, please keep it consistent.
Usage
import RNEasyUpgrade from 'react-native-easy-upgrade';
this.easyUpgrade = new RNEasyUpgrade({
  iOSAppId: '12345678',
  downloadTitle: 'Download package',
  downloadDescription: 'Packing downloading...',
  downloadApkEnd: () => {
   //eg: install apk
    this.easyUpgrade.installApk();
  },
  onError: () => {
    console.log('downloadApkError');
  }
});
async getUpdateInfo() {
  let updateInfo = {
    latestVersion: '3.0.0',
    hasNewVersion: true,
    apkUrl: 'http://{remoteApkDownloadUrl}'
  };
  if (isAndroid) {
    updateInfo = await fetch('http://{remoteUrl}/updateInfo.json')
  } else {
    updateInfo = await this.easyUpgrade.checkAppVersionIOS()
  }
  return updateInfo;
}
 async startUpgrade() {
    const updateInfo = await this.getUpdateInfo();
    if (updateInfo.hasNewVersion) {
      Alert.alert(
        'Find a new version: ' + updateInfo.latestVersion,
        'Whether to upgrade app?',
        [
          {text: 'Ask me later', onPress: () => console.log('Ask me later pressed')},
          {text: 'Upgrade', onPress: () => this.easyUpgrade.startAppUpdate(updateInfo.apkUrl)},
        ],
      )
    }
  }