I always find that when I push new package by code-push release-react [MyApp] ios -m, after device successfully update this new version, then when I close the app and reopen again, version will always rollback.
my first release bundle use react-native bundle --platfrom ios --dev false --entry-file index.ios.js --bundle-output ./bundles/main.jsbundle, I'm not sure why always back to this local bundle on device, what should I do?
thanks for your time.
The two most common reasons this can happen are:
sync on startup (e.g. you're calling it in a button click or on resume), and you're also not calling notifyApplicationReady on startup. The CodePush runtime needs to be told that the update was considered successful in order to prevent it from rolling back. The sync method calls notifyApplicationReady, so as long as you're calling it on app start, then you're fine, but otherwise, you need to make sure you're calling notifyApplicationReady somewhere in your startup process (e.g. the componentDidMount of your root component).AppDelegate.m file is configured to get the JS bundle location from the binary instead of from CodePush. This prevents CodePush from choosing which update to run on app start.Do any of those match your app? If not, could you look at the console logs of your app? The sync method logs a bunch of diagnostic messages and it may help indicate what the issue is.
@L-Jovi Any luck trying either of those workarounds?
@lostintangent thanks for your reply !
I follow that calling notifyApplicationReady in componentDidMount and it works fine now :)
Awesome! Thanks for confirming.
@lostintangent when does Code Push decide that an update was unsuccessful? For example, if I call sync() a minute after the app loads, is that too late?
@mvayngrib - notifyAppReady() (or sync(), which calls it internally), need to be called at some point in the first run of the update to mark it as successful. The second time the app is booted, it will check if the update was marked as successful. If not, it will be rolled back.
We recommend making one of these calls immediately in your root componentDidMount() (and in fact if you wrap your root component we do this for you), because the user could quit the app at any moment, including immediately after it loads. So, if you only have a single call to sync() a minute after the app loads, and a user quits the app 30 seconds into the first run of the update, it will be rolled back the next time the app is booted.
Note that the intent of the rollback feature is to ensure that your update is well formed and loads successfully, not that it is free of errors during the whole lifecycle of its execution. I hope this makes sense!
@silhouettes cool, that's more or less what I figured, but really appreciate for the in-depth answer!
Most helpful comment
The two most common reasons this can happen are:
syncon startup (e.g. you're calling it in a button click or on resume), and you're also not callingnotifyApplicationReadyon startup. The CodePush runtime needs to be told that the update was considered successful in order to prevent it from rolling back. Thesyncmethod callsnotifyApplicationReady, so as long as you're calling it on app start, then you're fine, but otherwise, you need to make sure you're callingnotifyApplicationReadysomewhere in your startup process (e.g. thecomponentDidMountof your root component).AppDelegate.mfile is configured to get the JS bundle location from the binary instead of from CodePush. This prevents CodePush from choosing which update to run on app start.Do any of those match your app? If not, could you look at the console logs of your app? The
syncmethod logs a bunch of diagnostic messages and it may help indicate what the issue is.