microsoft / react-native-code-push

React Native module for CodePush
http://appcenter.ms
Other
8.98k stars 1.47k forks source link

[iOS] Update not applied on app restart #2650

Closed bonesyblue closed 9 months ago

bonesyblue commented 9 months ago

Steps to Reproduce

The following code manually checks for the availability of a CodePush update and, if available, proceeds to download and install the update.

const update = await CodePush.checkForUpdate();

if (update) {
  const updateBundle = await update.download();
  // Update should be applied on next app restart.
  await updateBundle.install(CodePush.InstallMode.ON_NEXT_RESTART);
  await CodePush.notifyAppReady();
}

My root component:

const CodePushApp = CodePush({
  checkFrequency: CodePush.CheckFrequency.MANUAL,
})(AppWrapper);

export default CodePushApp;

Expected Behavior

When restarting the application, the update bundle is applied.

Actual Behavior

The update bundle is only applied if I explicitly call CodePush.restartApp(). However, the update is lost if I then restart the application.

💡 Note: There are no issues with the same code on Android.

Things I've Tried

I've followed the troubleshooting guide and enabled CodePush logs for my release target. There are no issues logged and the update appears to be successful.

[CodePush] Applying full update.
[CodePush] Verifying hash for folder path: ...
[CodePush] Manifest string: ( ...
[CodePush] Expected hash: ..., actual hash: ...
[CodePush] The update contents succeeded the data integrity check.
[CodePush] JWT signature verification succeeded, payload content: ...
[CodePush] The update contents succeeded the code signing check.

I also tried replacing my manual code by just calling CodePush.sync(), however, I experience exactly the same behaviour on iOS.

Environment

bonesyblue commented 9 months ago

Hi all 👋 I spent some time today examining the issue I described above. As I'm working on a production project, I created a separate fresh project for testing purposes. I'm pleased to report that I couldn't reproduce the issue described above in the new project, indicating that the problem I'm experiencing is not directly related to react-native-code-push.

I'll continue my investigation in the linked repository below, but for now, I'll close this issue.

https://github.com/bonesyblue/byte-sync

bonesyblue commented 8 months ago

I discovered that the issue was actually related to the expo-updates module. After removing expo-updates in my test project the CodePush OTAs began working as expected on iOS. 🚀

amanthegreatone commented 6 months ago

pls check this i had this issue which was solved. https://github.com/microsoft/react-native-code-push/issues/2529#issuecomment-1968788585