使用React-Native和应用程序重启的代码推送

zengzsys  于 2023-03-19  发布在  React
关注(0)|答案(2)|浏览(135)

我创建了一个使用react-native和code-push的应用,当我启动应用时,code-push会在服务器上查找更改,如果有更改,它会响应:

2017-03-03 11:33:10.919 [info][tid:com.facebook.react.JavaScript] [CodePush] Installing update.
2017-03-03 11:33:10.918777 MyApp[6646:4397574] [CodePush] Installing update.
2017-03-03 11:33:10.933 [info][tid:com.facebook.react.JavaScript] [CodePush] Update is installed and will be run on the next app restart.
2017-03-03 11:33:10.932649 MyApp[6646:4397574] [CodePush] Update is installed and will be run on the next app restart.

我现在的问题是:是否可以在安装更新后自动重启应用程序,这样用户就无需手动关闭和重启应用程序?
我在React原生客户端SDK中找到了一些方法,但仍然不确定如何以及在何处使用这些方法:
https://microsoft.github.io/code-push/docs/react-native.html#codepushrestartapp
希望有人能帮我解决这个问题?
更新:同时我想出了如何在不重新启动应用程序的情况下安装更新。现在安装在下一个应用程序恢复时执行,代码如下:

let codePushOptions = { checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, installMode: codePush.InstallMode.ON_NEXT_RESUME };
MyApp = codePush(codePushOptions)(MyApp);
8fsztsew

8fsztsew1#

mandatoryInstallModeIMMEDIATE一起使用:

mandatoryInstallMode: CodePush.InstallMode.IMMEDIATE

它表示您要立即安装更新并重新启动应用。

sauutmhj

sauutmhj2#

使用“代码推送.安装模式.立即”代替“代码推送.安装模式.ON_NEXT_RESUME”

相关问题