本篇会讲
- 如何使用自己公司的Code push 私有化部署
- 怎样关闭已更新的codepush包
一、如何使用自己公司的Code push 私有化部署(已android为例)

首先我们来看一下CodePush的源码
其中有个构造方法可以传入serverUrl
查看源码可知 当用户端不主动传serverUrl时默认使用的是👇Code push 自己的服务器。
private static String mServerUrl = "https://codepush.appcenter.ms/";
所以如果需要使用自己的服务器那么就需要传入 私服地址
new CodePush(CodePushDeploymentKey,getApplicationContext(), BuildConfig.DEBUG, selfcodepushServices)
//CodePushDeploymentKey 为Production的Deployment Key
//selfcodepushServices 自己的私服地址
那么在登录code push 账号的时候也是需要指定 私服地址的 命令如下👇
//需要先退出登录
code-push logout
//下面命令的codepushKey为注册codepush生成的Key
code-push login https:xxx.com --accessKey codepushKey
发布
- code-push release-react <Appname> <Platform> --t <本更新包面向的旧版本号> --des <本次更新说明> --m <是否强制更新 true 或 false> --dev <是否调试 true 或 false>
注意: CodePush默认是更新Staging 环境的,如果发布生产环境的更新包,需要指定--d参数:--d Production,
字段介绍 --m true强制更新 --dev 是否调试
- --m true强制更新
- --dev 是否调试
- --des "这是第一个更新包" 描叙
- --t 1.0.0 本更新包面向的旧版本号 且因为codepush 规定的版本号为三位。所以android工程中的版本号也需要改为三位
code-push release-react <projectName> android --t 1.0.0 --dev false --d Production --des "这是第一个更新包" --m true
二、怎样关闭已更新的codepush包
如果发生了我上面提到的发布出去的更新有bug或者重大崩溃,不想让更多的用户检测到此更新怎么办?这时你可以马上登录code-push官网https://microsoft.github.io/code-push/ 操作步骤如下图👇




网友评论