3

I created an app which uses react-native and code-push. When i start the app, code-push looks for changes on the server and if there are changes it responds with:

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.

My question is now: Is it possible to restart the App automatically when an update has been installed so the user doesn't need to close and restart the app manually?

I found some methods in the React native Client SDK but still not sure how and where to use these:

https://microsoft.github.io/code-push/docs/react-native.html#codepushrestartapp

Hope someone can help me out with this?

UPDATE: In the meantime i figured out how to install the update without restarting the app. Now the install is executed on next app resume with the following code:

let codePushOptions = { checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, installMode: codePush.InstallMode.ON_NEXT_RESUME };
MyApp = codePush(codePushOptions)(MyApp);
ManfredP
  • 1,037
  • 1
  • 12
  • 27

2 Answers2

0

use mandatoryInstallMode with IMMEDIATE:

mandatoryInstallMode: CodePush.InstallMode.IMMEDIATE

It indicates that you want to install the update and restart the app immediately.

alexrogo
  • 522
  • 3
  • 17
0

use "codePush.InstallMode.IMMEDIATE" instead of "codePush.InstallMode.ON_NEXT_RESUME"

Chris Nguyen
  • 2,327
  • 1
  • 16
  • 13