CodePush

作者: B1ngx | 来源:发表于2016-10-18 17:21 被阅读131次

热更新 codepush

步骤

  1. npm install -g code-push-cli
    安装 cli.
    code-push -v 查看版本信息:1.12.6-beta
  • code-push register
    在浏览器打开的页面选择认证方式,认证成功后跳转到 access key 页面(图一)。
    复制 key 在命令行执行,注册成功返回信息

Successfully logged-in. Your session file was written to C:\Users\BinG\AppData\Local.code-push.config. You can run the code-push logout command at any time to delete this file and terminate your session.

  • code-push app add <appName>
    注册 app 获取 key

Successfully added the "zyxldsapp" app, along with the following default deployments:
┌────────────┬───────────────────────────────────────┐
│ Name │ Deployment Key │
├────────────┼───────────────────────────────────────┤
│ Production ││
├────────────┼───────────────────────────────────────┤
│ Staging │ │
└────────────┴───────────────────────────────────────┘

  • npm install --save react-native-code-push
    安装 React Native module for CodePush

  • react-native link react-native-code-push
    图二
    rnpm link the plugin.

  • 修改 MainActivity.java 文件

new CodePush("deployment-key-here" , this , BuildCofig.DEBUG)

deployment-key-here 可以通过 code-push deployment ls zyxldsapp -k 命令查看
Staging 为测试阶段,Production 为生产环境
当应用开发完成,可使用 code-push promote 命令从 Staging 迁移到 Production.

  • code-push release-react <appName> <platform>
    CLI docs 发布更新
    mandatory -m 强制更新

  • updateDialog
    options
    optionalIgnoreButtonLabel Defaults to "Ignore"
    optionalInstallButtonLabel Defaults to "Install"
    optionalUpdateMessage Defaults to "An update is available. Would you like to install it?"
    title Defaults to"Update available"

  • 图例

图一 图二

相关文章

网友评论

      本文标题:CodePush

      本文链接:https://www.haomeiwen.com/subject/sgkpsttx.html