Closed jlong4223 closed 1 year ago
Got a workaround figured out thats working for me so ill close this issue. Did some refactoring:
Here's what ive got put together. I set up a "CodePushProvider
"
export const codePushKeys: { [key: string]: string | undefined } = {
staging: Platform.select({
ios: CodePushKeys.STAGING_IOS,
android: CodePushKeys.STAGING_ANDROID,
}),
prerelease: Platform.select({
ios: CodePushKeys.PRERELEASE_IOS,
android: CodePushKeys.PRERELEASE_ANDROID,
}),
production: Platform.select({
ios: CodePushKeys.PROD_IOS,
android: CodePushKeys.PROD_ANDROID,
}),
};
const checkIfLowerCPEnvSelected = async () => {
const res = await AsyncStorage.getItem('CP_LOWER_ENV');
return res;
};
function CodePushProvider() {
log('[SYNC] CodePush: Provider Setting up');
useEffect(() => {
codePush
.notifyAppReady()
.then(() => {
return checkIfLowerCPEnvSelected();
})
.then(lowerCPEnvSelection => {
if (lowerCPEnvSelection) {
log('[SYNC] CodePush: Beta Tester');
codePush.sync({
deploymentKey: codePushKeys[lowerCPEnvSelection],
installMode: codePush.InstallMode.IMMEDIATE,
});
} else {
log('[SYNC] CodePush: Production');
codePush.sync({
deploymentKey: codePushKeys.production,
installMode: codePush.InstallMode.ON_NEXT_RESTART, // default
});
}
})
.catch(() => {
logError('π ~ file: CodePushProvider.tsx:28 ~ codePush.notifyAppReady ~ error');
});
}, []);
return null;
}
export default codePush({
checkFrequency: codePush.CheckFrequency.MANUAL,
})(CodePushProvider);
Then im using this CodePushProvider
in App.tsx like so:
export function App() {
return (
<>
<Provider store={appStore}>
....<SomeCodeHere/>
</Provider>
<CodePushProvider />
</>
);
}
export default App;
I currently have a react native app setup with codepush for Android & iOS. iOS is working as expected and android works as expected with react native debug builds. On Android release builds or builds from Google Play, I allow a user to sync to
staging
for "beta testing". Based on native android studio logs, the sync & update install is successful. After restarting the app, I see the version change correctly to our apps staging version but moments later, there's a quick flash/restart, and then the app reverts back to the production version. There are no rollbacks in appcenter.I have attempted to disallow restarts.
Here are the logs I see in android studio logcat:
So it seems to be downloading & installing the correct version for Staging but then it will automatically load from the bundle and/or install the update for the production build with a auto restart instead of remain on the environment that I attempted to sync to.
React Native JSX Setup:
Expected Behavior
What you expected to happen? I expect it to remain on the environment that I manually synced to.
Actual Behavior
What actually happens? It syncs to the environment that I select and then reverts back to production/release.
STACK TRACE AND/OR SCREENSHOTS
No rollbacks
Heres the flash in action. It changes and then goes back: https://github.com/microsoft/react-native-code-push/assets/71945780/71cb3c27-1daa-4b03-a571-0b455b3bf8f7
Environment
(The more info the faster we will be able to address it!)