React Native · APIs and utilities
OTA updates
Update operations that can be called individually.
Import
Updates
moduleUpdate operations that can be called individually. Harmless without the native module (web, tests).
| Name | Type | Description |
|---|---|---|
isSupported | boolean | Whether the native module exists in this app. |
getState | () => Promise<UpdatesState> | State on the device. |
check | () => Promise<UpdateCheckResult> | Checks the server; does not download. |
fetch | () => Promise<UpdateFetchResult> | Checks; if there is a new update, downloads, verifies and stages it for the next launch. To run it immediately, call Updates.reload afterwards. |
reload | () => void | Reopens the app immediately with the pending update. On iOS the bundle is reloaded; on Android the process restarts (~1 s). |
markReady | () => void | Reports that the running update is healthy. Even if you do not call it, it is marked automatically when readyTimeout (default 10 s) expires or the app goes to the background; calling it early shortens the rollback guard. |
setChannel | (channel: string | null) => Promise<void> | Changes the channel for this device (e.g. moving test users to "beta"); null returns to the configured channel. Applies from the next check. |
reset | () => Promise<void> | Drops the downloads; the embedded bundle runs on the next launch. |
useUpdates
functionConnects the update state to a component: a "new version ready" banner, version info on a settings screen and so on. Optional; even without it updates download automatically on the native side and apply on the next launch.
UpdateManifest
interfaceSummary of an update in the manifest.
| Name | Type | Description |
|---|---|---|
id | string | Update id. |
createdAt | string | null | Publish time (ISO 8601). |
message | string | null | Note given when publishing (--message). |
critical | boolean | Marked critical (--critical): the app may want to apply it immediately. |
rollback | boolean | Rollback manifest: returns to the embedded bundle. |
extra | Record<string, unknown> | null | Extra data given when publishing (--extra). |
UpdatesState
interfaceUpdate state on the device.
| Name | Type | Description |
|---|---|---|
enabled | boolean | Whether updates are enabled in this build (release build + config). |
url | string | Manifest server. |
channel | string | Active channel (may have been changed for this device). |
runtimeVersion | string | Version of the native code; an update applies only to the same version. |
platform | string | "android" or "ios". |
updateId | string | null | The running update; null if the embedded bundle is running. |
isEmbedded | boolean | Whether the embedded (store) bundle is running. |
pendingId | string | null | Downloaded update that will run on the next launch ("embedded": return to the embedded one). |
confirmed | boolean | Whether the running update was marked healthy. |
lastRollback | { id: string; reason: string; at: number; } | null | Last rollback: which update, why ("crash", "missing"), when (ms). |
lastCheck | number | null | Last check time (ms). |
lastError | string | null | Last check error. |
manifest | UpdateManifest | null | Summary of the running update. |
Check result: none up to date, available a new update exists, rollback the server wants a return to the embedded bundle, excluded left out of a staged rollout, failed this update crashed on this device before, disabled updates are off (debug build or no config).
UpdateCheckResult
interfaceResult of Updates.check.
| Name | Type | Description |
|---|---|---|
status | UpdateCheckStatus | Check result. |
manifest | UpdateManifest | null | Manifest on the server (null if none). |
UpdateFetchResult
interfaceResult of Updates.fetch; status is "downloaded" if it was downloaded.
| Name | Type | Description |
|---|---|---|
status | UpdateCheckStatus | "downloaded" | Fetch result; "downloaded" if an update was downloaded. |
manifest | UpdateManifest | null | Manifest of the update on the server (null if none). |
UseUpdatesOptions
interfaceuseUpdates options.
| Name | Type | Default | Description |
|---|---|---|---|
fetchOnMount? | boolean | false | Checks and downloads when the component mounts. The native side already checks on launch (checkOnLaunch); this brings the result to the component. |
checkOnForeground? | boolean | false | Checks and downloads every time the app comes to the foreground. |
minInterval? | number | 300000` (5 min) | Minimum time between foreground checks (ms). |
applyCritical? | boolean | false | Applies a critical update immediately once downloaded. |
UseUpdatesResult
interfaceReturn value of useUpdates.
| Name | Type | Description |
|---|---|---|
state | UpdatesState | null | State on the device (null until the first read). |
phase | "idle" | "fetching" | What is happening right now. |
downloaded | UpdateManifest | null | Downloaded update waiting to be applied. |
error | Error | null | Last error. |
fetch | (): Promise<UpdateFetchResult> | Checks and downloads. |
apply | (): void | Applies the pending update immediately. |