Votor CodePushSign InHomeAboutInstallationTerms of servicePrivacy policyContact Us

Installing CodePush in a React Native App


This guide provides step-by-step instructions to integrate CodePush into your React Native application.

Prerequisites

Before you begin, ensure the following:

  1. You have Node.js (v14 or higher) installed.
  2. You have the React Native CLI installed.
  3. Your app is initialized using React Native.
  4. You have an Votor CodePush account.

Installation Steps

1. Install the CodePush Plugin

Install the react-native-code-push package using either npm or yarn and follow the installation instructions:

yarn add react-native-code-push

2. Configure Your App with CodePush

Modify your app's entry point to include CodePush functionality.

Example: App.ts

import React from 'react'
import codePush from 'react-native-code-push'

const codePushOptions = { checkFrequency: codePush.CheckFrequency.ON_APP_RESUME }

const MyApp:React.FC = () => {
   return (
      <Text>
        Hello from an app with CodePush
      </Text>
  )
}

export default codePush(codePushOptions)(MyApp)

3. Configure CodePush Keys

  • Sign in to Votor CodePush Admin: Votor CodePush Admin
  • Create a new app or navigate to an existing one.
  • Under App, there wil be deployment keys for both Staging, Production and other deployments.

For example, in android/app/src/main/res/values/strings.xml:

<string moduleConfig="true" name="CodePushServerUrl">https://votor.com</string>
<string name="CodePushDeploymentKey">YOUR_DEPLOYMENT_KEY</string>

For iOS, update the Info.plist:

<key>CodePushServerURL</key>
<string>https://votor.com</string>
<key>CodePushDeploymentKey</key>
<string>YOUR_DEPLOYMENT_KEY</string>

4. Test the Integration

  • Run the app using:
  npx react-native run-android
  npx react-native run-ios
  • Verify that the app communicates with the CodePush server for updates.

5. Push Updates via CodePush

  • Install the CodePush CLI:
    git clone https://github.com/microsoft/code-push-server /tmp/code-push-server
    cd /tmp/code-push-server/cli
    npm install && npm run build && npm install -g
    
  • Push updates (ACCESS_KEY can be found here):
    npx code-push-standalone login "https://votor.com" --key $ACCESS_KEY
    npx code-push-standalone release-react MySuperApp-ios ios -d Production --useHermes -e index.tsx
    npx code-push-standalone release-react MySuperApp-Android android -d Production --useHermes -e index.tsx
    

Troubleshooting

  • Deployment Key Errors: Double-check the deployment keys in your app configuration.

Additional Resources


You're all set to integrate and use CodePush in your React Native application!