所需环境:
数据库,nodejs,git
下载 code-push-server 仓库
git clone https://github.com/lisong/code-push-server.git
cd code-push-server && npm install
account: admin
password: 123456
修改默认配置,需要改动db模块配置数据库,local模块配置bundle下载配置
vi config/config.js
./bin/db init --dbhost localhost --dbuser root --dbpassword 数据库密码
./bin/www
客户端
npm install code-push-cli@latest -g
code-push register
code-push login
code-push whoami
code-push logout
code-push app add app名称
code-push app remove app名称
code-push app list
code-push access-key ls
code-push deployment add appName deploymentName
code-push deployment rm appName
code-push deployment ls appName
code-push deployment ls appName -k
code-push login http://localhost:3000
code-push app add CodePushDemoIos ios react-native
code-push app add CodePushDemoAndroid android react-native
code-push deployment ls CodePushDemoAndroid -k
React Native配置Code Push
npm install --save react-native-code-push
react-native link react-native-code-push
new CodePush("xxxxxxxxxxxxx", MainApplication.this, BuildConfig.DEBUG,"http://你的IP:端口/")
componentDidMount() {
CodePush.sync({
//启动模式三种:ON_NEXT_RESUME、ON_NEXT_RESTART、IMMEDIATE
installMode: CodePush.InstallMode.ON_NEXT_RESTART,
// 苹果公司和中国区安卓的热更新,是不允许弹窗提示的,所以不能设置为true
updateDialog: false
});
}