React-native-code-push: How can I not run codepush in debug mode? (CodePush keep runs in debug mode after implementing multi-deployment testing)

Created on 14 Sep 2020  路  4Comments  路  Source: microsoft/react-native-code-push

Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):

Steps to Reproduce

  1. Make a react native project
  2. Finish all setting progress as appcenter react native client SDK and codepush SDK
  3. Implement multi-deployment testing for both android and ios as recommended(set empty key for debug, and give keys for staging/production)

Expected Behavior

What you expected to happen?
codePush(App) does not check or download anything in debug mode.

Actual Behavior

What actually happens?

I have codePush function in my root app.js as this:

  codePush({
    checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
    installMode: codePush.InstallMode.ON_NEXT_RESUME,
  })(App)

I expected none of [CodePush] logs be seen in debug mode after implementing 'multi-deployment testing', but it seems to keep run and give some error as below

[Mon Sep 14 2020 15:29:13.715]  LOG      [CodePush] Checking for update.
[Mon Sep 14 2020 15:29:14.690]  LOG      [CodePush] An unknown error occurred.
[Mon Sep 14 2020 15:29:14.695]  LOG      [CodePush] 400: An update check must include a valid deployment key - please check that your app has been configured correctly. To view available deployment keys, run 'code-push deployment ls <appName> -k'.

I think I can handle this by getting the default codePushDeploymentKey from device on runtime(return a non-codepush-ifyed app component if it gives a empty key), but I cannot find any API reference which gives the deploymentkey value or status.

I'm always getting those [CodePush] LOGs in every refresh(since I configured as codepush to run on app-resume), and it pretty disturbs me on debugging.
I don't want to commentize codePush(App) part back and forth for every iteration.
Is there any way to not run codepush in debug mode?

Reproducible Demo

Environment

System:
  OS: macOS 10.15.6
  Shell: 5.7.1 - /bin/zsh
Binaries:
  Node: 14.9.0 - /usr/local/bin/node
  Yarn: 1.22.5 - /usr/local/bin/yarn
  npm: 6.14.7 - /usr/local/bin/npm
  Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
  Android Studio: 4.0 AI-193.6911.18.40.6514223
  Xcode: 11.7/11E801a - /usr/bin/xcodebuild
npmPackages:
  react: 16.13.1 => 16.13.1 
  react-dom: ^16.13.1 => 16.13.1 
  react-native: 0.63.2 => 0.63.2 
  react-native-web: ^0.13.9 => 0.13.9
  • react-native-code-push version: ^6.3.0
  • react-native version: 0.63.2
  • iOS/Android/Windows version: iOS=13.7
  • Does this reproduce on a debug build or release build? Debug Build
  • Does this reproduce on a simulator, or only on a physical device? I've only tested in physical device, but I think it will also happen in simulator

(The more info the faster we will be able to address it!)

Most helpful comment

Just use:

if (!__DEV__) {
  codePush({
    checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
    installMode: codePush.InstallMode.ON_NEXT_RESUME,
  })(App)
}

All 4 comments

Just use:

if (!__DEV__) {
  codePush({
    checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
    installMode: codePush.InstallMode.ON_NEXT_RESUME,
  })(App)
}

I don't even know that there was global variable __DEV__ haha...
Thank you so much!

Just use:

if (!__DEV__) {
  codePush({
    checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
    installMode: codePush.InstallMode.ON_NEXT_RESUME,
  })(App)
}

Where should I put this code?

Might wanna do something like this, this goes in the root component file, likely called App.js/App.tsx.

const codePushOptions = {
  checkFrequency: __DEV__ ? codePush.CheckFrequency.MANUAL : codePush.CheckFrequency.ON_APP_RESUME,
  // other options
};

export default codePush(codePushOptions)(App);

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevando picture kevando  路  4Comments

SudoPlz picture SudoPlz  路  4Comments

EdmundMai picture EdmundMai  路  4Comments

quanzaiyu picture quanzaiyu  路  3Comments

Fuhrmann picture Fuhrmann  路  3Comments