Giter Site home page Giter Site logo

contacts's Introduction

本例是一个带热更新的React Native App通讯录Demo 通讯录部分的代码引用了,并升级了RN的版本: https://github.com/chenbin92/React-native-example/blob/ListView-example/app/contact.js

本例可在android设备同时安装测试版和发布版,配置目录android/app/src/debug

  • 开发执行npm run start, 然后在模拟器中执行
npm run start

CodePush 作用

  • JS/Images 热更新
  • crash 自动回滚

版本支持

codepush 1.17兼容版本:

  • ios7+
  • android4.1+
  • rn0.41

为了保持兼容的版本自动使用rn小版本和codepush最新版本

"react-native": "~0.41.2",
"react-native-code-push": "^1.17.0-beta",

图片更新有限的支持请参考:

https://github.com/Microsoft/react-native-code-push#supported-components

教程

  1. 安装配置
npm install --save react-native-code-push@latest

使用rnpm自动配置,这个工具可以完成大部分工作但不是全部

react-native link react-native-code-push
  • android 修改 android/app/build.gradle
    android {
        ...
        buildTypes {
            debug {
                ...
                // CodePush updates should not be tested in Debug mode
                ...
            }
    
            releaseStaging {
                ...
                buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_STAGING_KEY>"'
                ...
            }
    
            release {
                ...
                buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_PRODUCTION_KEY>"'
                ...
            }
        }
        ...
    }
    
    修改 MainApplication
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
          new MainReactPackage(), new CodePush(BuildConfig.CODEPUSH_KEY, getApplicationContext(), BuildConfig.DEBUG)
      );
    }
    
  • ios 可参考官方教程 https://github.com/Microsoft/react-native-code-push#multi-deployment-testing
  1. 使用codepush,并且在开发时禁用,代码位置app/App.js
import codePush from "react-native-code-push";

let MyApp=App;
if (!__DEV__) {
  MyApp = codePush({ checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, installMode: codePush.InstallMode.ON_NEXT_RESUME })(App);
}
export default MyApp;

  1. 发布,为加强体验在ui上加了手动更新按钮
code-push release-react contacts android
code-push release-react contacts ios

contacts's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.