GithubHelp home page GithubHelp logo

react-native-org / react-native-easy-upgrade Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 5.0 11.69 MB

Easy to upgrade your react-native app

Home Page: https://react-native-org.github.io/react-native-easy-upgrade/

License: MIT License

JavaScript 23.89% Java 70.05% Objective-C 4.13% Ruby 1.93%
react-native app-upgrade

react-native-easy-upgrade's Introduction

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

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-easy-upgrade and add RNEasyUpgrade.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNEasyUpgrade.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. 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 the getPackages() method
  1. 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')
  1. 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)},
        ],
      )
    }
  }

react-native-easy-upgrade's People

Contributors

dependabot[bot] avatar hstarorg avatar sunnyever0 avatar xiapeixu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-easy-upgrade's Issues

"Detected problems with API compatibility"

启动是会报这个错,然后下载提示 ‘unable to create directory' 的错误,data/下没有 user/0文件夹,手动创建才可以,这不能提示用户手动去创建这几个文件夹吧,还有是否能返回下载进度呢,测试机型小米8

installApk Fail

Hello, is this feature complete? When I finished downloading apk, an exception occurred during the installation. The exception is shown. How to solve it?
image

求助

为什么npm下来的包缺少很多东西 没有安卓 ios 的依赖包,只有两个js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.