Blogs

Tutorial React Native Code Push

Tutorial React Native Code Push

React Native Codepush is plugin provides client-side integration for the CodePush service, allowing you to easily add a dynamic update experience to your React Native app(s).

I think you should look at this post https://github.com/Microsoft/react-native-code-push#ios

React Native CodePush Cheat Sheet | cmichel

And my way to do it:

  1. Install code-push

First, install the CodePush CLI:

npm install -g code-push-cli

Then go to root of your React Native project and use command line:

npm install --save react-native-code-push

Then link the libraries:

react-native link react-native-code-push

After that, we need to login in code-push with our account (you could find Mobile Center account here):

code-push login

You also could check if you're already logged in by using command:

code-push whoami


  1. Create Deployment Keys

Before we deploy any updates, we need to register an app with the CodePush service using the following command:

code-push app add <appName> <os> <platform>

For example:

code-push app add myapp-ios ios react-native

code-push app add my-android android react-native

After then you should see what you just added in Mobile Center https://mobile.azure.com/apps And next step is checking the Deployment Key by typing command line:

code-push deployment ls <appName> -k

For example:

code-push deployment ls myapp-ios -k

code-push deployment ls myapp-android -k


  1. Link Deployment Key

To release an update we need to link Deployment Key to React Native project. https://github.com/Microsoft/react-native-code-push#ios

 

  1. Release an update

After Deployment Key is finally setting up, the last step is upload the first update. Change index.ios.js and index.android.js file into:

import codePush from "react-native-code-push";
let codePushOptions = {
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
installMode: codePush.InstallMode.ON_NEXT_RESUME,
};

class MyApp extends Component {
...
}

export default MyApp = codePush(codePushOptions)(MyApp);

And now type the command line:

code-push release-react <appName> <platform>

e.g.

code-push release-react myapp-ios ios

code-push release-react myapp-android android

After this step you will see the first version is uploading to Mobile Center

The rest is now getting very easy. Anytime we want to do an update, we just need to type code-push release-react command line and the code-push will do the silent update.

Push staging to Production also just one command job:

code-push promote <APP_NAME> Staging Production -r 100%

Whatsapp