实现 React Naitve 热更新 (client && server) 客户端以及服务器端

目前针对react native 热更新的方案比较成熟的选择有microsoft公司的code-push 传送门,与react-native 中文网的pushy 传送门

本文选择code-push 用来进行对react-native 实现热更新,code-push 包含client端的配置,默认code-push 使用的服务器地址为微软的服务器,但是在国内的网速不是太好。因此可以使用code-push-server 搭建自己的服务器。本文主要介绍了实现热更新 client 和 server 端的配置。

React Native 热更新 借助 code-push-cli 脚手架完成
参考教程 https://blog.csdn.net/dounine/article/details/78529106
code-push 常用命令可查看 https://www.jianshu.com/p/aa296cc8a2cf
官方code-push 命令操作以及简介可查看 https://github.com/Microsoft/code-push/blob/master/cli/README-cn.md

1.react native 热更新 客户端配置
1.首先全局安装code-push-cli

npm install -g code-push-cli

2.然后注册一个code-push 账号(可使用github账号)

code-push register

3.注册成功后将获取的token在当前命令行输入并回车 (如下)

Enter your token from the browser:  b0c9ba1f91dd232xxxxxxxxxxxxxxxxx
#成功提示如下方
Successfully logged-in. Your session file was written to /Users/huanghuanlai/.code-push.config. You can run the code-push logout command at any time to delete this file and terminate your session.

如使用自己搭建的code-push-server 可忽略 2 ,3 步骤 并使用以下命令登录到code-push-server

登录可采用以下命令

code-push login  http://***.***.***.***

4.使用code-push 添加一个 app

code-push app add AppName android react-native

添加成功后

code-push app add AppName android react-native
#成功提示如下方
Successfully added the "dounineApp-android" app, along with the following default deployments:
┌────────────┬──────────────────────────────────────────────────────────────────┐
│ Name       │ Deployment Key                                                   │
├────────────┼──────────────────────────────────────────────────────────────────┤
│ Production │ PZVCGLlVW-0FtdoCF-3ZDWLcX58L6dec4087-57cf-4c9d-b0dc-ad38ce431e1d │
├────────────┼──────────────────────────────────────────────────────────────────┤
│ Staging    │ T0NshYi9X8nRkIe_cIRZGbAut90a6dec4087-57cf-4c9d-b0dc-ad38ce431e1d │

5.在自己项目中安装react-native-code-push

npm install react-native-code-
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值