Hi, I don't add codepush to my Root component.
My problem is that my release allways rollbacks when I relaunch the app.
I understand that I need to call codePush.notifyApplicationReady
In a sub component, I have this code:
componentDidMount() {
codePush.sync({ updateDialog: {
appendReleaseDescription: true,
descriptionPrefix: '\n\nChange log:\n',
},
installMode: codePush.InstallMode.IMMEDIATE });
codePush.notifyAppReady()
}
With this code, my release rollbacks again.
Should I call codePush.notifyAppReady() before codePush.sync()?
After?
Or in another way (within a callback for example)?
@benjaminb10, even if you don't want to call sync in the root component you'll still need to call notifyAppReady() there - it's essential to call it at the very beginning of app's lifecycle. Calling it right after the sync, as in your example, is not a good idea as in this case it would report bogus data to codepush service
@vladimir-kotikov Thanks for your reply.
The thing is that I'm using this Navigation package: https://github.com/wix/react-native-navigation
And so my index.ios.js file is:
import { Navigation } from 'react-native-navigation'
import MySubComponent from './App/Components/MySubComponent'
export function registerScreens () {
Navigation.registerComponent('MySubComponent', () => MySubComponent)
}
registerScreens()
Navigation.startSingleScreenApp({
screen: {
screen: 'MySubComponent',
}
})
Where do I have to import codepush and call notifyAppReady() ?
Something like that doesn't seem to work:
import codePush from "react-native-code-push";
import { Navigation } from 'react-native-navigation'
import MySubComponent from './App/Components/MySubComponent'
export function registerScreens () {
Navigation.registerComponent('MySubComponent', () => MySubComponent)
}
registerScreens()
codePush.notifyAppReady()
Navigation.startSingleScreenApp({
screen: {
screen: 'MySubComponent',
}
})
Something like that doesn't seem to work
Hmm... It actually should work. Have you tried to remove the app from device/emulator before deploying it using react-native run-*. Could you please also share the output of code-push debug <ios|android> command?
@vladimir-kotikov What do you mean by:
Have you tried to remove the app from device/emulator before deploying it using react-native run-*
I'm not quite sure whether this would really help, though, but rationale here is that code-push stores some metadata about already installed updates in application's data directory, which may affect how new updates are being fetched, so you might want to unistall app from device/emulator first to wipe app metadata and then try to run it again.
@vladimir-kotikov so you suggest me to delete the app on my iPhone (long press on it), there release it again?
Yes, delete and then re-install. Also could you please run code-push debug <ios|android> (depending on platform you're running app on) before and share the output to make it easier to understand why the update is being rolled back?
@benjaminb10 Pinging you to see if this fixes the issue. I am closing this issue for now, but if you still have issues, please let us know and we will be glad to help out.
I have a similar situation, using wix navigation, and it's not working, always rollback-ing when i close the app. Spent the past few hours trying to make it work.
What I did:
1) Initially there wasn't any code refresh at all, so I had to make sure in AppDelegate.m i have jsCodeLocation = [CodePush bundleURL]; as detailed in the manual installation instructions (I used react-native link initially, but due to the wix navigation, AppDelegate.m somehow got mixed up)
2) tried deleting the app from the device, doesn't help
3) tried calling codePush.notifyAppReady() in index.ios.js, in my main component's componentDidMount(), on a button click. Didn't help. Whenever I close the app and reopen it, it rolls back to the previous code.
Any ideas, did anyone make this work?
Ok, I finally solved the problem like this https://github.com/Microsoft/react-native-code-push/issues/875