GithubHelp home page GithubHelp logo

rayshen / mxhotdog Goto Github PK

View Code? Open in Web Editor NEW
42.0 7.0 9.0 402 KB

react-native 自建热更新版本升级工具 demo ios

Python 0.40% Java 0.30% JavaScript 0.53% Objective-C 12.39% C 81.07% C++ 5.32%

mxhotdog's Introduction

MXHotdog

react-native 自己搭建版本升级的demo ios

运行iOS工程可以看到效果。

初始为1.0.0版本,然后更新后升级到1.0.1版本。

打包方式:

1.在RN工程目录新建一个文件夹,比如叫bundle-ios

2.每次打包用下面的命令:

react-native bundle --platform ios --dev false --entry-file index.ios.js --bundle-output ./bundle-ios/main.jsbundle --assets-dest ./bundle-ios

会把工程内的资源和JS都打包出来,放入bundle-ios文件夹,分别是assets文件夹和main.jsbundle文件

3.然后将assets和main.jsbundle压缩成zip文件,放到服务器,也就是我工程里需要下载的ZIP包的URL

由于工作较忙,这里只是提供一个实现的简单思路。距离实际完美的框架还太远。

主要流程是这样:

APP打开时,通过接口判断本地版本和远程版本差异,如果需要更新,可将远程的JS和assets文件压缩包下载到本地并解压,然后刷新APP即可完成更新。

几个可优化的点:

1.远程接口里包含版本更新的配置项,比如某版本(1)强制更新JSBundle(2)弹框可选更新(3)需要更新原生APP 这个版本的管理,需要一个后端服务器和数据库的支持。

2.将原生启动更新的函数桥接给RN,这样可以由RN触发更新操作。

3.更新的进度回调:下载bundle的时候,原生可以把进度传递给RN,然后RN来做界面。

欢迎交流,我的博客是:http://www.cnblogs.com/rayshen/

mxhotdog's People

Contributors

rayshen avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mxhotdog's Issues

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.