微软的React Native热更新(1)

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提供的多种功能:

1、可以团队合作:App Management

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({

updateDialog:

true,

installMode: codePush.

InstallMode.

IMMEDIATE

});

}

}

codePush.sync方法会去服务器同步,询问是否有可更新的包,如果有则会弹出确定框让用户选择是否更新,如果没有则没反应,如果用户同意更新则会去下载更新包,并且安装好后及时失效,无需重新打开应用生效。

If you would like your app to discover updates more quickly, you can also choose to sync up with the CodePush server every time the app resumes from the background.

从后台拉起更新(每次resume都会去拉去最新版本,但是不会生效,下一次开启应用才会生效):

const codePushOptions = { checkFrequency: codePush.

CheckFrequency.

ON_APP_RESUME };

@codePush(codePushOptions)

export

default

实战系列

话不多说,Android实战系列集合都已经系统分类好,由于文章篇幅问题没法过多展示



《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》点击传送门,即可获取!
9.

});

}

}

codePush.sync方法会去服务器同步,询问是否有可更新的包,如果有则会弹出确定框让用户选择是否更新,如果没有则没反应,如果用户同意更新则会去下载更新包,并且安装好后及时失效,无需重新打开应用生效。

If you would like your app to discover updates more quickly, you can also choose to sync up with the CodePush server every time the app resumes from the background.

从后台拉起更新(每次resume都会去拉去最新版本,但是不会生效,下一次开启应用才会生效):

const codePushOptions = { checkFrequency: codePush.

CheckFrequency.

ON_APP_RESUME };

@codePush(codePushOptions)

export

default

实战系列

话不多说,Android实战系列集合都已经系统分类好,由于文章篇幅问题没法过多展示

[外链图片转存中…(img-Qm5N7WE1-1715305555537)]
[外链图片转存中…(img-O8wLiDiQ-1715305555537)]
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》点击传送门,即可获取!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值