I am using AppCenter for OTA updates for my react-native app and it is giving me some weird behaviour here. (Testing in android) I pushed a codepush update to app center and the target version is 1.0 with label v1. I then increased the versionCode from 1 to 2 and changed the versionName from 1 to 1.0.1. And I did push a new release. Now in the releases there is a release with version 1.0.1. I installed this release on my android but I am getting that a new update is available
This is how I am checking for updates:
useEffect(() => {
const checkForCodePushUpdate = () => {
CodePush.checkForUpdate()
.then(update => {
console.log('update', update);
if (update) {
CodePush.sync(
{
updateDialog: {
title: 'New Update Available',
optionalUpdateMessage:
'Update available. Proceed with installation?',
optionalIgnoreButtonLabel: 'Later',
optionalInstallButtonLabel: 'Yes',
mandatoryContinueButtonLabel: 'Yes',
mandatoryUpdateMessage:
'Update available. Proceed with installation?',
},
installMode: CodePush.InstallMode.IMMEDIATE,
},
status => {
if (status === CodePush.SyncStatus.DOWNLOADING_PACKAGE) {
setDownloading(true);
}
if (status !== CodePush.SyncStatus.DOWNLOADING_PACKAGE) {
setDownloading(false);
}
},
progress => {
const _progressPercent = Math.round(
(progress.receivedBytes / progress.totalBytes) * 100,
);
console.log('_app update progress percent', _progressPercent);
setProgressPercent(_progressPercent);
},
);
}
})
.catch(err => {
console.log('app update error', err);
});
};
AppState.addEventListener('change', state => {
if (state === 'active') {
checkForCodePushUpdate();
}
});
checkForCodePushUpdate();
}, []);
And I have wrapped my App with
export default codepush({checkFrequency: codepush.CheckFrequency.MANUAL})(App);
In the console.log("update", update) inside the information the label is v1 but the appVersion is 1.0.1
Why is this happening? What I am trying here is to mimick releasing apps to playstore after an update has been released previously. The users that install the app from the playstore shouldn't be getting that a new update is available after they just installed the app and specifically the app in playstore is indeed updated after the releasing a codepush update.
The reason was because when a codepush update targets a version like 1.0 it applies to all patch releases like 1.0.x. So your update should target 1.0.0 instead of 1.0 if you don't want to consider it an update in 1.0.1