This guide provides step-by-step instructions to integrate CodePush into your React Native application.
Before you begin, ensure the following:
Install the react-native-code-push package using either npm or yarn and follow the installation instructions:
yarn add react-native-code-push
Modify your app's entry point to include CodePush functionality.
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)
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>
npx react-native run-android
npx react-native run-ios
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
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
You're all set to integrate and use CodePush in your React Native application!