如果已经注册过使用
code-push login
会打开浏览器,我是选择github账号登录,在命令行粘贴token,回车即可登录。
登录成功会返回:
Successfully logged-in. Your session file was written to /Users/hfmoney/.code-push.config. You can run the code-push logout command at any time to delete this file and terminate your session.
3、注册应用以及管理应用:
注册应用:
code-push app add <appName>
不同平台使用不同的名字,比如android和ios两个平台就创建两个应用,MyProjectAndroid和MyProjectIOS。
注册成功会返回:
Paste_Image.png
staging代表开发版的热更新部署,production代表生产版的热更新部署。
在ios中,将staging的部署key复制在info.plist的CodePushDeploymentKey值中。
在android中,复制在Application的getPackages的CodePush构造中。
NOTE: As a reminder, you can retrieve these keys by running code-push deployment ls <APP_NAME> -k from your terminal.
4、集成RN
import codePush
from
“react-native-code-push”;
…
@codePush
export
default
class App extends Component {
…
}
By default, CodePush will check for updates on every app start. If an update is available, it will be silently downloaded, and installed the next time the app is restarted (either explicitly by the end user or by the OS), which ensures the least invasive experience for your end users.
5、打release包,然后在修改rn代码或者rn方的图片资源等。
6、发布rn的bundle到微软服务器:
code-push release-react <AppName> <PlatName>
会自动先执行:”react-native bundle” 命令打包:
code-
push release-react MyProject ios
node node_modules
/react-native/
local-cli
/cli.js bundle --assets-dest /
var
/folders/g5
/f8hqh2bn3dl9942583b0c7tr0000gn/T
/CodePush --bundle-output /
var
/folders/g5
/f8hqh2bn3dl9942583b0c7tr0000gn/T
/CodePush/main.jsbundle --dev
false --entry-
file
index.ios.js –
platform ios
打包完成后会自动上传到热更新服务器:
Releasing
update
contents
to CodePush
Upload progress:[==================================================]
100%
0.0s
Successfully released
an
update containing
the
“/var/folders/g5/f8hqh2bn3dl9942583b0c7tr0000gn/T/CodePush”
directory
to
the
“Staging” deployment
of
the
“MyProjectIOS” app.
7、查看发布的历史记录:
code-push deployment histroy MyProjectIOS Staging
刚发布:
Paste_Image.png
正在下载:
Paste_Image.png
下载完毕:
Paste_Image.png
热更新成功。
Android和iOS的区别
1、if you are targeting both platforms it is recommended to create separate CodePush applications for each platform.
2、Android 的 release版本的发布:打包APK
3、code-push release-react <AppName> <PlatName>
注意平台名称。
code-push release-react <appName> <platform>
[--bundleName <bundleName>]
[--deploymentName <deploymentName>]
[--description <description>]
[--development <development>]
[--disabled <disabled>]
[--entryFile <entryFile>]
[--gradleFile <gradleFile>]
[--mandatory]
[--noDuplicateReleaseError]
[--outputDir <outputDir>]
[--plistFile <plistFile>]
[--plistFilePrefix <plistFilePrefix>]
[--sourcemapOutput <sourcemapOutput>]
[--targetBinaryVersion <targetBinaryVersion>]
[--rollout <rolloutPercentage>]
For more details about how the release-react command works, as well as the various parameters it exposes, refer to the CLI docs
热更新的版本控制
版本中前缀~,^,和没有前缀的区别: semver range expression.
官方的热更新指定版本参数说明:TARGET BINARY VERSION PARAMETER
Android的版本查看:The android.defaultConfig.versionName property in your build.gradle file
iOS的版本查看:The CFBundleShortVersionString key in the Info.plist file
在release-react
时不指定targetBinaryVersion
参数时,会从以上目录下查看版本号,并对该版本进行打包更新。
NOTE: If the app store version in the metadata files are missing a patch version, e.g. 2.0, it will be treated as having a patch version of 0, i.e. 2.0 -> 2.0.0.
code push提供的多种功能:
2、可以修改metadata数据:Patching Update Metadata。
3、可以回滚更新:Rolling Back Updates。
4、可以debug code push,实时查看code push的状态:
Paste_Image.png
NOTE: The debug command supports both emulators and devices for Android, but currently only supports listening to logs from the iOS simulator. We hope to add device support soon.
5、可以将发布到部署在Staging的更新在经过测试无误后发布到Production中去: Promoting Updates
进阶:
If an available update is mandatory, then it will be installed immediately, ensuring that the end user gets it as soon as possible.
用户手动检查更新:
const codePushOptions = {
checkFrequency: codePush.
CheckFrequency.
MANUAL };
class App extends Component
{
…
_onPress =
() => {
codePush.sync({
题外话
不管怎么样,不论是什么样的大小面试,要想不被面试官虐的不要不要的,只有刷爆面试题题做好全面的准备,当然除了这个还需要在平时把自己的基础打扎实,这样不论面试官怎么样一个知识点里往死里凿,你也能应付如流啊
这里我为大家准备了一些我工作以来以及参与过的大大小小的面试收集总结出来的一套进阶学习的视频及面试专题资料包,主要还是希望大家在如今大环境不好的情况下面试能够顺利一点,希望可以帮助到大家~
欢迎评论区讨论。
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门,即可获取!
d device support soon.
5、可以将发布到部署在Staging的更新在经过测试无误后发布到Production中去: Promoting Updates
进阶:
If an available update is mandatory, then it will be installed immediately, ensuring that the end user gets it as soon as possible.
用户手动检查更新:
const codePushOptions = {
checkFrequency: codePush.
CheckFrequency.
MANUAL };
class App extends Component
{
…
_onPress =
() => {
codePush.sync({
题外话
不管怎么样,不论是什么样的大小面试,要想不被面试官虐的不要不要的,只有刷爆面试题题做好全面的准备,当然除了这个还需要在平时把自己的基础打扎实,这样不论面试官怎么样一个知识点里往死里凿,你也能应付如流啊
这里我为大家准备了一些我工作以来以及参与过的大大小小的面试收集总结出来的一套进阶学习的视频及面试专题资料包,主要还是希望大家在如今大环境不好的情况下面试能够顺利一点,希望可以帮助到大家~
[外链图片转存中…(img-AM8OpWtS-1715305590190)]
欢迎评论区讨论。
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门,即可获取!