codepush2之配置自己的服务器
来源:互联网 发布:淘宝达人帐号简介范例 编辑:程序博客网 时间:2024/06/06 09:44
这片文章是给使用过codepush的人看的如果没有用过codepush请参考http://blog.csdn.net/u014041033/article/details/73497708这篇文章。
codepush会去访问微软的服务器,在国内网速特别慢基本上和不能用没有什么区别。今天我们就来配置自己的服务器。
好处
1:网络不受限制
2:自是服务器端变化了codepush的命令依旧可以使用功能上不受影响。
配置步骤
这里我们以本地服务器为例。
服务器端:
一:下载mysql https://dev.mysql.com/downloads/mysql/数据库
然后运行状态:
二:
git clone https://github.com/lisong/code-push-server.git
cd code-push-server
npm install
修改code-push-server/config/config.js配置文件
1:配置db
db: { username: "root", password: "xxx", database: "codepush", host: "127.0.0.1", port: 3306, dialect: "mysql", logging: false },
2:配置local
local: { // Binary files storage dir, Do not use tmpdir and it's public download dir. storageDir: "/Users/wuyunqiang/Documents/db/storage",//自定义 // Binary files download host address which Code Push Server listen to. the files storage in storageDir. downloadUrl: "http://127.0.0.1:3000/download",//这里ip+端口改成本地的 // public static download spacename. public:'/download' },
3:配置jwt
jwt: { // Recommended: 63 random alpha-numeric characters // Generate using: https://www.grc.com/passwords.htm 随便写点什么 貌似没啥用 不过还是更具网站的随机生成一个吧 tokenSecret:'xxxxxxxx....' },
4:配置common
common: { // data dir for caclulate diff files. it's optimization. 配置数据存储位置。 dataDir: "/Users/wuyunqiang/Documents/db/data", storageType: "local", },
三:初始化数据库
code-push-server-db init –dbhost localhost –dbuser root –dbpassword password//初始化数据库用户名和密码
四:启动数据库./bin/www 启动服务
客户端
一:登录自己的服务器
因为我是本地服务器所以 code-push login http://127.0.0.1:3000/
登录窗口 用户名admin 密码:123456
获取token复制到终端。
二:添加要热更新的APP
code-push app add appname android/ios react-native
三:将添加app获取的key配置到Android/iOS的代码中
四:
Android配置src/java/名字/MainApplication
new CodePush("xxxxxx", getApplicationContext(), BuildConfig.DEBUG,"http://172.28.108.3:3000/")
服务器的ip,我配置的是本地网址 http://172.28.108运行在手机上的不能是127.0.0.1。
ios:配置info.plist
<key>CodePushDeploymentKey</key> <string>xxx</string> <key>CodePushServerURL</key> <string>http://172.28.108.3:3000/</string>
以上服务器和客户端配置完成。
使用
InteractionManager.runAfterInteractions(() => { CodePush.sync({ updateDialog: { appendReleaseDescription:true, descriptionPrefix:'更新内容:', mandatoryContinueButtonLabel:'更新', mandatoryUpdateMessage:'有新版本了,请您及时更新', optionalInstallButtonLabel: '立即更新', optionalIgnoreButtonLabel: '稍后', optionalUpdateMessage:'有新版本了,是否更新?', title: '提示' }, installMode: CodePush.InstallMode.IMMEDIATE }); })
改过后的应用上传:
code-push release-react <添加的APPName> android/ios –t 1.0.0(版本) –d Staging/Production –des “更新提示” -m false
上传文件成功后可以在/Users/wuyunqiang/Documents/db/data和/Users/wuyunqiang/Documents/db/storage看到文件
运行截图:
bug:
1:
这是数据库安装的问题。卸了再重新安装。
2:
客户端地址错误。
iOS可能是info.plist的字段写错了,注意大小写.
3:android端可以收到更新提示框,但是点击下载更新就会报错如图。
原因:这个原因是因为config里面downloadUrl配置有问题,这里即便是自己本机作为服务器也不要127.0.0.1 换成电脑的ip即可。
4:另外注意收集和电脑要在同一个网段先才能访问到你电脑。
- codepush2之配置自己的服务器
- 配置自己的Linux svnserve服务器
- 新手如何配置自己的Tomcat服务器
- 配置自己的Linux svnserve服务器
- 用自己的电脑配置服务器
- 配置自己的Linux svnserve服务器
- 配置自己的VPN服务器ubuntu16
- Linux下配置自己的Git服务器
- 配置自己的ss服务器(AWS)
- 配置服务器禁止所有非法域名 访问自己的服务器
- 如何配置自己的服务器接入微信服务器
- 微信开启服务器配置,确定是自己的服务器
- 自己的读书笔记之web服务器
- 搭建自己的服务器之Web服务器父与…
- win7配置自己的IIS服务器亲自做的图文...
- linux上配置svnserve服务,搭建自己的svn服务器
- 花生壳动态域名-用花生壳配置自己的电脑作为服务器
- Ubuntu NFS服务器的配置(绿色为自己添加)
- 第11周项目5-迷宫问题之图深度优先遍历解法
- IEEE 754标准
- (四)团队间使用pch或编写宏
- Spring boot 初次探访与服务器部署
- 同余方程(扩欧)
- codepush2之配置自己的服务器
- UE4 HTC VIVE
- 如何确定该线程是否为主线程
- Oracle 11g数据库软件在Windows7上的完全卸载
- C 单链表
- Intent以及IntentFilter详解
- java异常:The processing instruction must begin with the name of the target.
- 第十一周项目2-操作用邻接表存储的图
- proe5.0零件图添加文字问题