minimumBackgroundDuration seems to not working
Steps to Reproduce
- Add the following CodePush config:
import CodePush from 'react-native-code-push';
CodePush.sync({
minimumBackgroundDuration: Time.ONE_MINUTE * 5,
installMode: CodePush.InstallMode.ON_NEXT_SUSPEND
})
or:
import CodePush from 'react-native-code-push';
export default CodePush({
minimumBackgroundDuration: Time.ONE_MINUTE * 5,
checkFrequency: CodePush.CheckFrequency.ON_APP_RESUME,
installMode: CodePush.InstallMode.ON_NEXT_SUSPEND
})(App);
- Install the app and launch it for the first time.
Expected Behavior
CodePush update will be downloaded, but installed after app is being on a background for at least 5 minutes.
Actual Behavior
App reloads instantly.
BUNDLE [android, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1/1), done.
LOG Running "App" with {"rootTag":1}
LOG [CodePush] Checking for update.
LOG [CodePush] Reporting binary update (1.0)
LOG [CodePush] Downloading package.
LOG [CodePush] Installing update.
LOG [CodePush] Restarting app
BUNDLE [android, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1/1), done.
LOG Running "App" with {"rootTag":11}
LOG [CodePush] Checking for update.
LOG [CodePush] Reporting CodePush update success (v17)
LOG [CodePush] App is up to date.
Reproducible Demo
This is pretty much all the info I could provide. Have tried InstallMode.ON_NEXT_RESUME and InstallMode.ON_NEXT_SUSPEND - both are behaving the same way.
Environment
- react-native-code-push version: 6.2.0
- react-native version: 0.61.5
- iOS: 13.3.1, Android: 9
- Both debug and release builds.
- Both simulator and physical device
Any updates on this?
Hi @s-aleinik, @feiyingx Thank you for reporting!
We found a problem with the ON_NEXT_SUSPEND mode but in other modes the minimumBackgroundDuration works as expected. We are currently working on this issue. Сurrent PR: #1863.
Please let me know if you have any questions.
@andreidubov have you also checked android behavior?
@s-aleinik yes, unfortunately, I do not know about Time.ONE_MINUTE, so I tried
CodePush.sync({
minimumBackgroundDuration: 60 * 5,
installMode: CodePush.InstallMode.ON_NEXT_SUSPEND
})
and
CodePush.sync({
minimumBackgroundDuration: 60 * 5,
installMode: CodePush.InstallMode.ON_NEXT_RESUME
})
These configurations worked correctly and I did not have any problems, I think that you can try to replace Time.ONE_MINUTE because it can lead to the wrong data format.
Please let me know if it was helpful or you have any questions.
@andreidubov yes, Time.ONE_MINUTE is simply 60. I have tried with 60 * 5 as well, but app was restarting after being 5-10 sec or even 1-2 sec on a background on android with both modes. I will check it again tomorrow.
Thank you for your responses!
Hi @s-aleinik,
I'm going to close this issue for now. Please feel free to reopen it if you have any questions.
Thanks, Andrei
@andreidubov Hi! I think I found a possible issue. For me CodePush.sync() works in a correct way only if I provide mandatoryInstallMode to options, even if update is not mandatory. So for not a mandatory update:
const options = {
minimumBackgroundDuration: Time.ONE_MINUTE * 0.25,
installMode: CodePush.InstallMode.ON_NEXT_SUSPEND,
rollbackRetryOptions: {
delayInHours: 2.5,
maxRetryAttempts: 5
}
};
CodePush.sync(options);
restarts immediately, but
const options = {
minimumBackgroundDuration: Time.ONE_MINUTE * 0.25,
installMode: CodePush.InstallMode.ON_NEXT_SUSPEND,
mandatoryInstallMode: CodePush.InstallMode.ON_NEXT_SUSPEND,
rollbackRetryOptions: {
delayInHours: 2.5,
maxRetryAttempts: 5
}
};
CodePush.sync(options);
works fine and restarts only after being more than 15 sec on a background.
Platform: iOS, react-native-code-push: 6.3.0, react-native: 0.62.2
Will check Android later
works for android as well