React Native 热更新

CodePush 是微软提供的一套用于热更新 React Native 和 Cordova 应用的服务。现在已经开源,可以依据源代码自己搭建一套属于自己的code push server,可以通过npm安装。

  • 安装code-push-server
    1. git clone https://github.com/lisong/code-push-server.git
    2. cd code-push-server
    3. npm install
    4. 初始化数据库
    5. 修改config.js配置
  • 启动code-push-server
    • 切换到work账户,nohup /home/work/code-push-server/bin/www &
    • 在浏览器中打开 http://127.0.0.1:3000,到此服务器端到配置就完成了。
    • 使用admin/123456登录,获取access_token。
  • 安装code-push客户端
    1. npm install -g code-push-cli,等待运行完即可。

                                                  CODE PUSH 相关操作


  • 登录code-push客户端
    • code-push login http://127.0.0.1:3000,然后输入浏览器获取到的access-key。
      Successfully logged-in. Your session file was written to /Users/XX/.code-push.config. You can run the code-push logout command at any time to delete this file and terminate your session.
  • 注册APP
    1. code-push app ls
    2. code-push app ls -help
    3. code-push app add hluser-app-ios-rn ios react-native
    4. code-push app add hluser-app-android-rn android react-native
  • 发布bundle

    1. code-push release -help
    2. code-push release hluser-app-ios-rn /home/work/ios "*" --des "base" -m true
    3. code-push release hluser-app-ios-rn -d Production /home/work/ios "*" --des "base" -m true
      app已经创建好了,其他的也已经配置好了,就差发布一个更新版本来进行测试了,发布到code-push服务器上的是bundle文件,所以需要先把js文件打包成bundle文件。code-push发布应用步骤上是需要先把本地js文件打包成bundle文件,然后再发布。
  • 查看
    1. code-push deployment ls -help
    2. code-push deployment ls hluser-app-ios-rn --displayKeys
    3. code-push deployment ls hluser-app-ios-rn -k
  • 回滚
    1. code-push rollback hluser-app-ios-rn Staging --targetRelease v3
  • 清除
    1. code-push deployment clear hluser-app-ios-rn Staging
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
回答: React Native热更新是指在不需要重新发布和重新安装应用程序的情况下,通过更新应用程序的JavaScript代码来实现应用程序的更新。在安卓平台上,可以通过插件实现应用的热更新,但是在iOS上却无法实现。这是因为苹果对应用的审核标准非常严格,并且发版速度较慢,所以热更新能力对于iOS应用显得尤为重要。在React Native中,可以使用CodePush插件来实现热更新CodePush插件提供了一组API,可以用于获取当前已安装更新的元数据、检查是否有更新可用并下载更新等操作。具体的代码可以参考CodePush的示例应用中的demo.js文件,这个文件中包含了每次启动应用程序时检查更新和下载的代码。通过使用CodePush插件,开发者可以方便地实现React Native应用的热更新功能。123 #### 引用[.reference_title] - *1* [快速了解react native 热更新](https://blog.csdn.net/wangbaobao512/article/details/127241775)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] - *2* *3* [React Native CodePush 最新配置](https://blog.csdn.net/maomaoyu3211/article/details/84908556)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值