My company released v1 of the app and is already available to the public. We are trying to release v2 and deprecate v1. The next step is to do a CodePush release on v1 to guide the users to download the new version v2. However, I did not develop v1 and I am not able to get it to build because of all the dependencies and some errors that are not worth fixing for the matter.
I removed the dependencies and was able to run the app on an empty view, which is enough for me to redirect the user to download the new version.
My main question is, am I able to do a CodePush using a new environment with all the third party dependencies (including dependencies with native code) removed as if I'm pushing a brand new app, form a new machine. Is there other approach I should take?
Yes. Since it's not the other way around (adding _new_ dependencies that require native modules), you're not accessing any _native features_ that don't already exist. You're just removing access to the already existing native features.
So given that, you should be in the clear.
Thank you for your reply!
Just to summarize, in theory I can have an app as developed and with as many features as for example Instagram, with code-push installed, and at any point in time I can just edit the index.js file to just do:
import React from 'react'
import {AppRegistry} from 'react-native'
AppRegistry.registerComponent('instagram', () => React.Fragment);
And also only leave react and react-native as dependencies in the package.json file and a code-push will work?
Hi @LuisRizo
Sorry for long delay.
Yeah, I think that react and react-native will be enough for code-push. But please don't forget that code-push also has dependencies: https://github.com/Microsoft/react-native-code-push/blob/master/package.json
About native modules: You can't change native code throw CodePush as CodePush works just with JsBundles. For changing native code you should make new binary version of your app.
Could you please clarify if it was helpful for you or you have any questions.
Thanks,
Alexander
Hi @alexandergoncharov,
Thank you for your reply!
My goal is to use a code-push to deprecate v1 of our app and guide our users to update to v2 since we'll also deprecate the back-end hooked up to v1. My dependencies are just enough to render a simple screen saying to the users that they should update. That includes react, react-native and, of course, code-push. I did an npm install so that should take care of the peer dependencies of those packages.
The reason behind changing native code is that the dependencies are old and some of them have been deprecated and cause bugs that are not worth fixing. I am not using new native code, I just uninstalled it to get the app to run on ios and android without compilation errors.
So if deleting, and stopping using native code will not cause my code-push to be rolled back automatically, I think I'm all set!
Please let me know if something isn't clear, or not correct
Hi @LuisRizo ,
Sorry for long delay.
So, if I understand you correctly, you would like to remove some native code from your app.
For this you should make new binary version with this changes and deliver it to your end-users. Before delivering you can also check that code-push work correct and try to update app on you test device. If I understand you correct you can sent some instructions to users with your app for getting this new binary version. And then you can continue make updates with codepush.
Please let me know if it was helpful or I understand your issue incorrect or you have any questions.
Thanks,
Alexander
Hello @alexandergoncharov,
Thank you again for your reply! This might help you understand my situation a bit more:
Let me give a more visual example:
I have an app, say v1.4.0 in the play store and apple store. This app works, but it's an old app. It has many native dependencies like:
The repository that holds this app did not keep track of releases and kept doing commits and upgraded the version up to, say v1.5.0, but this was never pushed to the app store.
So now we want to deprecate this app, so we created a whole new react-native project to replace this old app and we will call it v2.0 It has the same idea but it's built totally different. For example, we are now using relay instead of redux.
Now I need to make a code-push to the old app (v1.4.0) that our end-users have that would look like this:
// file name: index.js
import React, { Component } from 'react';
import { AppRegistry, Image, Platform, Linking, StyleSheet, View, Text, TouchableOpacity } from 'react-native'
import codePush from "react-native-code-push";
import logoImage from './images/logo.png'
import pic from './images/pic.jpg'
class Deprecated extends Component {
openNewApp = () => {
const newAppURL = "https://website.com"
Linking.openURL(newAppURL)
}
render() {
return(
<View style={styles.mainContainer}>
<View style={styles.imageContainer}>
<Image
source={pic}
style={{
flex: 1,
width: undefined,
height: undefined,
}}
/>
</View>
<View style={styles.logoContainer}>
<Image
source={logoImage}
style={{
flex: 1,
width: undefined,
height: undefined,
}}
/>
</View>
<View style={styles.textContainer}>
<Text style={styles.shadowText}>
<Text style={[styles.shadowText, styles.boldText]}>Update Required{'\n'}</Text>
Update to our latest app to get the most out of this app!
{'\n'}
</Text>
<TouchableOpacity style={styles.buttonContainer} onPress={this.openNewApp}>
<Text style={styles.styledText}>Update</Text>
</TouchableOpacity>
</View>
</View>
)
}
}
class MainApp extends Component {
}
MainApp = codePush({ checkFrequency: codePush.CheckFrequency.MANUAL })(Deprecated);
const styles = StyleSheet.create({
...
})
AppRegistry.registerComponent('oldapp', () => MainApp);
As you can see, this removes access to any of the other screens we were previously using, as well as the native installations except for CodePush, leaving an app with a single screen with a link to open our website to download the v2.0 app.
However, I could not find the code used to create version v1.4.0 due to the repository not keeping track of the versions. So my idea is to use the code in v1.5.0, change the version back to v1.4.0 and make the changes here and do a CodePush.
Here is where the deletion of the native installations came in. All these packages installed even in v1.5.0 are old and they create compilation errors that are not worth for me to fix since I'm not going to use any of those packages. Therefore, I deleted all of those packages (like react-native-firebase), including in native code, and left only the necessary dependencies to get the code on the snippet above to run.
After all this, my question is, will doing a CodePush like code-push release-react oldApp --targetBinaryVersion "1.4.0" work even though I am not using the same codebase that was used to create v1.4.0?
Also, releasing a new binary with the code above will more likely be rejected by the corresponding stores, so releasing a new binary is not an option.
Hi @LuisRizo,
Thanks for this details!
Yeah, I got it. So, I think that it should works. It should not broke app If your new update will not use some installed plugin in your v1.4.0 app.
But I think it will be better if you'll test installing this update on your local device to ensure that all this works correct in your case if it is possible.
I just tested it with test project and didn't find some issues.
Please let me know if it was helpful for you and then results of your work.
Thanks,
Alexander
Hello @alexandergoncharov,
Thank you for your time and your response!
I appreciate you tested it locally! I'm really happy you found no issues. We're going to be doing this deployment soon so I will definitely let you know how it goes!
Thank you very much again for all.
Best,
Luis Rizo
@LuisRizo I was glad to help. You are always welcome :)
So, if question is answered I'm going to close this issue for now but please feel free to reopen it if you have any questions.
And I will be waiting your result.
Thanks,
Alexander
UPDATE: we tried doing the code-push update with that snippet code above to our own test devices, and it worked out great!
The live version of the app had 1rn-splash-screen1 though, and I did forget to put the code to hide it. A simple npm install of the library using the same version as app v1.4.0 worked out beautifully as the native config for it was already in place.
One more thing that I noticed is that there is no way to actually rollback a release. Rollback just prevents future installations, I was hoping it would uninstall the last update on all the affected users.