Quick Start Guide
This guide walks through the shortest supported path to get SrcPush running in a bare React Native app.
Prerequisites
Before you begin, ensure you have:
- a bare React Native application
- Node.js installed
- npm or yarn
- a Source Push account
1. Install the CLI
See the CLI Installation guide.
2. Create your account and log in
Create an account in the Source Push Console, then authenticate the CLI:
srcpush login
3. Create apps for each platform
srcpush app add MyApp-iOS
srcpush app add MyApp-Android
4. Install the React Native package
yarn add @srcpush/react-native-code-push
Or:
npm install --save @srcpush/react-native-code-push
5. Apply the native setup
iOS
- add
pod 'CodePush', :path => '../node_modules/@srcpush/react-native-code-push'toios/Podfile - run
cd ios && pod install - update
AppDelegateto return[CodePush bundleURL]in release builds - add placeholder values to
Info.plist
Android
- add
apply from: "../../node_modules/@srcpush/react-native-code-push/android/codepush.gradle"toandroid/app/build.gradle - keep
CodePushDeploymentKeyin a single source of truth, eitherbuild.gradleorstrings.xml - override
getJSBundleFile()inMainApplicationto returnCodePush.getJSBundleFile()
For the exact file-level changes, use:
6. Wrap your root component
import codePush from "@srcpush/react-native-code-push";
const codePushOptions = {
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
installMode: codePush.InstallMode.ON_NEXT_RESTART,
mandatoryInstallMode: codePush.InstallMode.IMMEDIATE,
updateDialog: false,
};
function App() {
return null;
}
export default codePush(codePushOptions)(App);
7. Add release scripts
{
"scripts": {
"srcpush:android:staging": "srcpush release-react YOUR_APP_NAME_ANDROID android -d Staging --privateKeyPath ./keys/private.pem --useHermes",
"srcpush:android:prod": "srcpush release-react YOUR_APP_NAME_ANDROID android -d Production --privateKeyPath ./keys/private.pem --useHermes",
"srcpush:ios:staging": "srcpush release-react YOUR_APP_NAME_IOS ios -d Staging --privateKeyPath ./keys/private.pem --plistFile ./ios/YOUR_APP/Info.plist --useHermes",
"srcpush:ios:prod": "srcpush release-react YOUR_APP_NAME_IOS ios -d Production --privateKeyPath ./keys/private.pem --plistFile ./ios/YOUR_APP/Info.plist --useHermes"
}
}
8. Publish your first update
yarn srcpush:ios:staging
yarn srcpush:android:staging
After validating the staging release, publish production:
yarn srcpush:ios:prod
yarn srcpush:android:prod