ps:命令在终端默认目录下java
1.安装Code-push cli -- $ npm install -g code-push-clireact
2.注册CodePush帐户 -- $ code-push register (点击弹出的网页的github注册,记录好返回的access token)android
3.终端输入access token ios
4.添加CodePush应用 -- $ code-push app add XXX //xxx 为你要热部署的app namegit
成功后咱们能够看到有两个发布键值。一个Production是对应生产环境的,二Staging是对应开发环境的github
│ Name │ Deployment Key │ ├────────────┼───────────────────────────────────────┤ │ Production │ xxxxx │ ├────────────┼───────────────────────────────────────┤ │ Staging │ xxxxx
ps:之后命令在项目的根目录下npm
1.在应用中安装react-native插件 -- npm install --save react-native-code-pushreact-native
2.npm i rnpm服务器
3.rnpm link react-native-code-pushapp
4.命令行这个时候须要输入咱们以前得到的key,相应输入,便可配置完环境(注意这里要选择是正式版的key--Production仍是测试版的key--Staging,不是发布到appstore能够用Staging的key)
5.xocde -> info.plist -> Bundle versions string, short 以及 studio -> build.gradle -> versionName 均将1.0 改成1.0.0
6.在studio的MainApplication.java还须要另外加上staging
import com.microsoft.codepush.react.CodePush; public class MainApplication extends Application implements ReactApplication { @Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), //*************只改动这里,添加这行代码 ******************/ new CodePush("你的staging", MainApplication.this, BuildConfig.DEBUG) //*******************************/ ); } }; }
7.js入口处 加上
import codePush from "react-native-code-push"; //后台自动下载更新,从新进入app的时候更新 componentDidMount(){ codePush.sync(); } //点击肯定的时候 更新 codePush.sync({ updateDialog: true, installMode: codePush.InstallMode.IMMEDIATE });
ps:如下命令均在工程根目录下:
1. react-native bundle --platform(platform) --entry-file (入口) --bundle-output codepush.js --dev false
模板: react-native bundle --platform android --entry-file index.android.js --bundle-output codepush.js --dev false react-native bundle --platform ios --entry-file index.ios.js --bundle-output codepush.js --dev false
2.code-push release(项目名称) codepush.js (版本号)
模板: 简单:code-push release MyProject codepush.js 1.0.0 默认生产环境: mandatory表明是否强制更新 code-push release MyProject codepush.js 1.0.0 --mandatory true 生产环境: code-push release MyProject codepush.js 1.0.0 -d "Production" --mandatory true 当咱们须要给用户测试的时候,能够先测试环境下发布给多少人更新,而后再正式版更新 1)有多少百分比的人能收到更新: rollout表明百分比 code-push release MyProject codepush.js 1.0.0 --rollout 20 2)code-push release MyProject codepush.js 1.0.0 -d "Production" --mandatory true 3)code-push promote <appName> <sourceDeploymentName> <destDeploymentName> //promote copy文件服务器的意思
CodePush经常使用与项目的命令:
ps:code-push app add XXX
1.“Could not get BatchedBridge, make sure your bundle is packaged properly”
http://stackoverflow.com/questions/38870710/error-could-not-get-batchedbridge-make-sure-your-bundle-is-packaged-properly
2.Gradle build-info.xml not found for module app. Please make sure that you are using gradle plugin '2.0.0-alpha4' or higher.
http://blog.csdn.net/my_chen_suo_zhang/article/details/51469001