My code-push is working on simulator but when i ran same app on device it shows me update dialog but when i press install nothing happens.
class MyApp extends React.Component {
constructor () {
super();
this.state = {
logs: []
}
}
codePushStatusDidChange(status) {
let msg = '';
switch(status) {
case codePushComponent.SyncStatus.CHECKING_FOR_UPDATE:
msg = ("Checking for updates.");
break;
case codePushComponent.SyncStatus.DOWNLOADING_PACKAGE:
msg = ("Downloading package.");
break;
case codePushComponent.SyncStatus.INSTALLING_UPDATE:
msg = ("Installing update.");
break;
case codePushComponent.SyncStatus.UP_TO_DATE:
msg = ("Up-to-date.");
break;
case codePushComponent.SyncStatus.UPDATE_INSTALLED:
msg = ("Update installed.");
break;
}
}
codePushDownloadDidProgress(progress) {
console.log(progress.receivedBytes + " of " + progress.totalBytes + " received.");
}
update () {
codePushComponent.sync({
updateDialog: true,
installMode: codePushComponent.InstallMode.IMMEDIATE
},() => this.codePushStatusDidChange,() => this.codePushDownloadDidProgress);
}
render(){
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome
</Text>
<Text style={styles.instructions}>
Update version 1.0
</Text>
<Button title="Update" onPress={() => this.update()} />
</View>
)
}
}
export default (MyApp)
Hi @awnali, thanks for reaching us. I've reproduced the issue you are experiencing using your code and the app also does not install an update in Release on Device for me, but I did not manage to repro the issue using our demo.js file. Could you please try our demo.js and let us know if the issue is still reproduced or not? If so - we'll try to figure out the root cause of the issue you have. Thanks for the patience.
Hello @awnali, seems that there is no issues with your code however I've found the following:
I was able to reproduce the issue (that looks very similar to the situation you have described) with the following repro steps:
1) Create new app with new deployment key and with provided RN and code-push plugin versions
2) Build app in Debug mode
3) Produces several updates in debug mode, verify it is working great
4) Change scheme to Release mode and build the app again with xCode (do not change anything on js side!)
5) Produce new update and verify it is not working
So to verify if this assumption is true could you please do the following: clear deployment history for your deployment (code-push deployment clear AppName DeploymentName), install Release app once again and produce new releases to verify if it works.
It seems that this issue could be related to the situation when packageHash's are the same for newly installed app when switching between different schemes and plugin failed to determine if this is the 1st update or it is a diff update. That is why we recommend to use different deployment keys for different schemes.
BTW you could also increment the app version when switching between release modes to overcome this issue.
Please let us know if the info from above helps.
@sergey-akhalkov @max-mironov so the issue was my build version wasn't matching with my last installed app on device. May be this is very childish mistake but as i'm very new to this world, so we can close it. Thank you so much for your prompt reply though!
Just wrote an ReadMe on github, so that others won't spend that much time on simple integration.
export default codePush(MyApp) :)
Most helpful comment
@sergey-akhalkov @max-mironov so the issue was my build version wasn't matching with my last installed app on device. May be this is very childish mistake but as i'm very new to this world, so we can close it. Thank you so much for your prompt reply though!
Just wrote an ReadMe on github, so that others won't spend that much time on simple integration.
https://github.com/awnali/CodePush-ReactNative-SampleApp