Implement CodePush in your mobile app

To implement CodePush in your mobile app follow the below steps:

1. Set up CodePush account:

  • Visit the CodePush website (https://microsoft.github.io/code-push/) and create an account if you haven't already.

  • Note down your CodePush account details (e.g., username and access token) as you'll need them later.

2. Configure your mobile app project:

  • Make sure you have a working React Native project for your Real Dev Squad mobile app.

  • Install the CodePush CLI by running the following command in your terminal:

    npm install -g code-push-cli
  • Navigate to your project directory and log in to your CodePush account using the following command:
    code-push login
  • Follow the prompts to provide your CodePush account details and authenticate the CLI.

3. Install the CodePush SDK in your React Native app:

  • Open a terminal and navigate to your project directory.

  • Run the following command to install the CodePush SDK:

    npm install react-native-code-push --save
  • Link the CodePush package with your project by running:
   react-native link react-native-code-push

4. Initialize CodePush in your app:

  • Open your app's entry file (usually index.js or App.js).

  • Import the CodePush package at the top of the file:

    import codePush from 'react-native-code-push';
  • Wrap your app component with the CodePush higher-order component (HOC) and export it:
    const MyApp = () => { /* Your app component code */ };
    export default codePush(MyApp);

5. Configure CodePush deployment keys:

  • Generate deployment keys for your app using the CodePush CLI. Run the following command in your project directory:
    code-push deployment ls <YourAppName> -k
  • You'll receive two keys: a Staging key and a Production key.

  • Open your app's AndroidManifest.xml file for ANdroid.

  • Add the following lines within the appropriate section of your configuration files, replacing <YourDeploymentKey> with the respective deployment key: xml

    <!-- For Android (AndroidManifest.xml) -->
    <meta-data android:name="reactNativeCodePush_androidDeploymentKey" android:value="<YourDeploymentKey>" />

6. Upload your app's initial release:

  • Build your app for release using your preferred method (e.g., react-native run-android --variant=release or react-native run-ios --configuration=Release).

  • Once built, create an initial release in the CodePush server by running the following command in your project directory:

    code-push release-react <YourAppName> <Platform>
  • Replace with your app's name and with either android or ios.

7. Deploy updates:

  • Whenever you want to deploy updates to your app, create a new release using the following command:
    code-push release-react <YourAppName> <Platform>

Summary:

CodePush will bundle your app and upload the update to the server. Users running your app will be notified and prompted to install the update. These steps should help you integrate CodePush into your Real Dev Squad mobile app and enable over-the-air updates. Remember to consult the official CodePush documentation for more detailed information and advanced configuration options.