Skip to content

Commit 343f5e2

Browse files
icarusdusttirth-patel-ncCopilot
authored
CodePush updates control (#3459)
* CodePush updates control Explains how to have control over launching updates * Update telegram.md (#3433) * Update telegram.md * Update content/yaml-notification/telegram.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Codepush analytics (#3460) * codepush analytics with other options * codepush analytics * api removal * few more clarifying points --------- Co-authored-by: Tirth Patel <tirth@nevercode.io> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent abcf85d commit 343f5e2

4 files changed

Lines changed: 74 additions & 12 deletions

File tree

content/rn-codepush/concepts.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ CodePush updates this **JavaScript bundle and its assets**. As long as JS remain
7474

7575
## What can and cannot be updated
7676

77-
Can Be Updated via CodePush (OTA-safe):
77+
Can Be Updated via CodePush (OTA-safe):
7878

7979
* Fixing JavaScript bugs
8080
* UI or layout adjustments
@@ -85,16 +85,21 @@ CodePush updates this **JavaScript bundle and its assets**. As long as JS remain
8585

8686
These updates modify only the JavaScript bundle, so they can be safely delivered over the air.
8787

88-
Require a New App Release
88+
Require a New App Release
8989

9090
* Adding or modifying native modules
9191
* Upgrading React Native or native dependencies
9292
* Editing native configuration files (build.gradle, Info.plist, etc.)
9393
* Changing app permissions (camera, location, etc.)
9494
* Adding platform-specific features or integrations
9595

96-
These changes affect compiled native code, so they must go through the App Store or Play Store.
96+
These changes affect compiled native code, so they must go through the App Store or Play Store.
9797

98+
### Delta updates
99+
100+
CodePush uses delta updates (file-level diffs) for each release and delivers only the JavaScript files and assets that changed.
101+
102+
Instead of redownloading a complete bundle and all static assets on every update, users receive a smaller delta package. This keeps OTA updates faster and reduces bandwidth usage.
98103

99104
## How the update flow works
100105

@@ -113,6 +118,21 @@ The update replaces the previously installed JavaScript bundle while keeping the
113118

114119
If an update fails or causes the app to crash on startup before it is marked as successful, the client can automatically revert to the previous working bundle.
115120

121+
### Prerequisite: a native build with the SDK
122+
123+
Because CodePush relies on the client SDK to check the server, download bundles, and swap the JS layer at launch, **the SDK must already be present in the native binary running on each user's device**. A store build that does not include the SDK cannot install OTA updates — `release-react` will still publish the bundle, but no client will pick it up.
124+
125+
The first time you add CodePush to an existing app, you therefore need to:
126+
127+
1. Integrate the SDK in your React Native project (see [Setup](/rn-codepush/setup/)).
128+
2. Produce a native build that includes the SDK and the deployment key you want to target.
129+
3. Install that build on the devices you expect to receive updates — local dev machines or QA devices for **Staging**, App Store / Google Play for **Production**.
130+
4. Only then start shipping JS changes to that deployment as OTA updates.
131+
132+
For Staging validation this usually just means running a fresh debug build on a test device; no store release is required. For Production, end users must actually update to the new store binary before they can receive anything CodePush publishes.
133+
134+
After that, the usual pattern — occasional native releases for native changes, OTA releases for everything else — applies.
135+
116136
## Deployment model
117137

118138
CodePush organizes updates using **apps** and **deployments**.

content/rn-codepush/releasing-updates.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Think of this as a single pipeline with two decision points:
8585

8686
CodePush delivers only JavaScript runtime assets and the files required by the application’s JS layer.
8787

88-
A typical update includes:
88+
A typical update includes only changed files and assets, such as:
8989

9090
* JavaScript bundle
9191
* Static assets (images, fonts, etc.)
@@ -95,6 +95,12 @@ CodePush does not include native binaries such as **.apk** or **.ipa** files. OT
9595

9696
Any modification involving native code (e.g. Swift, Objective-C, Java, Kotlin, or native modules) must be released through the App Store or Google Play.
9797

98+
### Delta updates
99+
100+
CodePush uses delta updates (file-level diffs) for each release and delivers only the files or assets that changed.
101+
102+
This means users download a lightweight delta package instead of the full JavaScript bundle and all assets every time, resulting in faster updates and smaller downloads for users.
103+
98104
## Version control
99105

100106
CodePush uses a two-layer versioning model that separates native app versions from JavaScript update versions. This ensures updates are only delivered to compatible app binaries while still allowing fast OTA iteration.

content/rn-codepush/setup.md

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,45 @@ function App() {
176176
export default codePush(App);
177177
{{< /highlight >}}
178178

179-
This enables the SDK to automatically check for updates on app start (or based on your chosen update strategy).
179+
This enables the SDK to automatically check for updates on app start (or based on your chosen update strategy). By default, CodePush looks for updates each time the app launches. When an update is found, it downloads it quietly in the background and applies it the next time the app restarts, whether triggered by the user or the operating system. If you want your app to detect updates faster, you can configure it to sync with the CodePush server whenever the app returns from the background:
180+
181+
{{< highlight bash "style=paraiso-dark">}}
182+
let codePushOptions = {
183+
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
184+
};
185+
186+
class MyApp extends Component {}
187+
188+
MyApp = codePush(codePushOptions)(App);
189+
{{< /highlight >}}
190+
191+
Alternatively, if you need more precise control over when update checks occur—such as after a button tap or at scheduled intervals—you can invoke CodePush.sync() whenever needed with your preferred SyncOptions. You can also disable CodePush’s automatic update checks by setting the checkFrequency to manual:
192+
193+
{{< highlight bash "style=paraiso-dark">}}
194+
let codePushOptions = { checkFrequency: codePush.CheckFrequency.MANUAL };
195+
196+
class MyApp extends Component {
197+
onButtonPress() {
198+
codePush.sync({
199+
updateDialog: true,
200+
installMode: codePush.InstallMode.IMMEDIATE,
201+
});
202+
}
203+
204+
render() {
205+
return (
206+
<View>
207+
<TouchableOpacity onPress={this.onButtonPress}>
208+
<Text>Check for updates</Text>
209+
</TouchableOpacity>
210+
</View>
211+
);
212+
}
213+
}
214+
215+
MyApp = codePush(codePushOptions)(App);
216+
217+
{{< /highlight >}}
180218

181219
### CodePush iOS Setup (React Native)
182220

@@ -346,13 +384,6 @@ This single command:
346384

347385
For the full release workflow, see [Releasing updates](/rn-codepush/releasing-updates/).
348386

349-
✅ Best Practices
350-
* Use Environment Variables – Avoid hardcoding deployment keys.
351-
* Separate Staging and Production Keys – Always validate updates in Staging before promoting to Production.
352-
* Confirm Connectivity – After configuration, make sure the app can fetch updates from the server by testing a Staging release.
353-
354-
Properly configuring the server URL and deployment keys ensures that CodePush can deliver OTA updates reliably and safely for each platform.
355-
356387
## Next steps
357388

358389
After completing setup, use the following sections to continue:

content/yaml-quick-start/building-a-react-native-app.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ If you are going to publish your app to App Store Connect or Google Play, each u
274274
{{< include "/partials/publishing-android-ios.md" >}}
275275

276276

277+
## OTA Updates with CodePush
278+
279+
Our hosted CodePush service lets you publish OTA updates for React Native projects directly to users' devices, without going through the App Store or Google Play. Read the [concepts page](../rn-codepush/codepush-concepts/) for how it works, or the [setup page](../rn-codepush/setup-codepush/) to get started.
280+
281+
277282
## Conclusion
278283
Having followed all of the above steps, you now have a working `codemagic.yaml` file that allows you to build, code sign, automatically version and publish your project using Codemagic CI/CD.
279284
Save your work, commit the changes to the repository, open the app in the Codemagic UI and start the build to see it in action.

0 commit comments

Comments
 (0)