Beta
The SDK API and its configuration keys can still change. See What Beta means.
This page describes how the SDK (react-native-notti-ota, plus react-native-notti-ota-expo for Expo) behaves. To install it, use the SDK install guide.
JavaScript API
Optional: the native layer works without it.
import { addUpdateReadyListener, getCurrentRelease } from 'react-native-notti-ota';
const { releaseId, isEmbedded } = await getCurrentRelease();
const subscription = addUpdateReadyListener(({ releaseId, mandatory }) => {
if (mandatory) {
// Ask the user to restart the app; the SDK never restarts it.
}
});
subscription.remove();| Function | Returns |
|---|---|
getCurrentRelease() | A promise of { releaseId: string | null, isEmbedded: boolean }: the Live update this session runs, or { releaseId: null, isEmbedded: true } for the bundle embedded in the binary. |
addUpdateReadyListener(listener) | A subscription (remove() unsubscribes). The listener receives { releaseId: string, mandatory: boolean }. |
The update-ready event
addUpdateReadyListener fires when an update has been downloaded and verified. It loads on the next cold start: the SDK never switches bundles in a running session and never restarts the app. mandatory is true when the release was published as mandatory (or a release the device skipped was; see mandatory updates); use it to ask the user to restart.
Subscribe early, for example in your root component. The download often finishes a few seconds after launch, and a listener added later misses that event.
Configuration keys
Set these in Info.plist (iOS) and as <meta-data> in AndroidManifest.xml (Android). The Expo config plugin writes them for you from its options. With a key missing or any value invalid, Live updates stay off and the embedded bundle is used.
| Key | Expo plugin option | Value |
|---|---|---|
NottiOTAAppId | appId | Notti App ID (UUID). |
NottiOTABaseUrl | baseUrl | Notti URL, https://app.zeepnotti.app or your self-hosted URL. |
NottiOTAClientKey | clientKey | The App's client key (public, device-restricted). |
NottiOTAChannel | channel | Release channel, [a-z0-9-]{1,32}. |
NottiOTARuntimeVersion | runtimeVersion | Your runtime version. |
NottiOTAPublicKeys | publicKeys | 1 to 5 signing public keys. Native value: comma-separated key_id:base64. Plugin: PEM strings. |
On Android a meta-data value that looks like a decimal number (1.10) is read as a float and refused: use 1.10.0. How to build the key_id:base64 value is in the install guide.
Launch and rollback
The SDK decides which bundle to run before any JavaScript starts, then watches the launch.
- Selection. The newest verified update, or the bundle embedded in the binary. A new binary (store update, new build) discards every downloaded update.
- Checking. After the app shows its first content, the SDK checks for an update in the background, and again when the app returns to the foreground, at most every 30 minutes. The download is verified (signature and every file hash) and kept for the next cold start.
- A new update is pending until a launch proves it works.
- Success: content on screen for 3 seconds without a fatal error. The release becomes the stable one and the SDK reports
applied. - Failed launch: a crash (a JavaScript fatal error or a native crash), or no content within 10 seconds (the watchdog) after the app came to the foreground.
- Interrupted launch: the user or the OS ended the launch without a crash (for example the app was swiped away). 3 interrupted launches count as 1 failed launch.
- Success: content on screen for 3 seconds without a fatal error. The release becomes the stable one and the SDK reports
- The 2-failure rule. After 2 failed launches the SDK goes back to the previous stable release (or the embedded bundle), blocks the failed release on that device and reports
rolled_back. - Background launches never count. A launch in the background (a push, a background fetch) is not a launch attempt, so it cannot fail a release.
- After
applied, the SDK never rolls the release back on its own. To stop a stable release, disable it in the dashboard (devices move on their next check). - Server revert. When no release of the device's runtime is enabled any more, the server tells the device to go back to the embedded bundle on the next cold start (
reverted_to_embedded).
iOS and Android differences
| iOS | Android | |
|---|---|---|
| Where you hook in | bundleURL() of your factory delegate (AppDelegate.swift, or SceneDelegate.swift on React Native 0.88+). | jsBundleFilePath in MainApplication.kt. |
| Telling a crash from an interruption | iOS has no API for why the last process ended. The SDK arms a crash marker while a launch is being judged: chained handlers for uncaught exceptions and fatal signals (SIGABRT, SIGSEGV, SIGBUS, SIGILL, SIGTRAP, SIGFPE) that always pass the crash on to the handlers installed before them, so crash reporters keep working. A leftover launch with a marker is a failed launch (crash); without one it is interrupted. | On Android 11 (API 30) and newer the SDK reads the system's process exit reason: a crash, native crash, ANR or initialization failure is a failed launch, and a user stop, low memory kill or similar is interrupted. Below API 30 the reason is unknown and the launch counts as a failed launch (crash). |
| Kills the SDK cannot see | A process killed with no catchable signal (out of memory, an OS watchdog kill, SIGKILL) counts as interrupted. | |
| Debug builds | Always load from Metro; the SDK stays off, selects nothing, changes no state and reports nothing. | Same, and a host running with developer support also turns the SDK off for the session. |
Other things that differ in practice:
- On iOS, a JavaScript error thrown while the bundle loads in a bare app does not reach the fatal handler: the app stays up with no content and the release is rolled back as
watchdog. The Expo iOS host does call the fatal handler (crash). - iOS
bundle_overriddenis only detected when the app's JavaScript importsreact-native-notti-ota.
More known limits are in Troubleshooting.
Events the SDK sends
The SDK reports device events to Notti, which counts them per release in the dashboard. Events carry no personal data, are queued on the device (the 50 newest are kept) and are sent in batches. Each has a type and, for some, a reason.
| Event | Reasons | Sent when |
|---|---|---|
downloaded | An update was downloaded and verified. | |
applied | A release ran for 3 seconds without a fatal error and became the stable one. | |
download_failed | network, http_status, timeout, no_space | The download failed. |
verification_failed | signature, unknown_key, hash, incompatible, invalid_path, invalid_archive | The update failed a check and was not run. |
rolled_back | crash, watchdog, interrupted | The SDK left a release after its failed launches. |
reverted_to_embedded | server | The server said no release of the runtime is enabled; the device goes back to the embedded bundle. |
integration_missing | Live updates are configured but the app never asked the SDK for its bundle. Once per binary. | |
bundle_overridden | The app loaded another bundle than the one the SDK selected; Live updates are off for that session. |
What each reason means and how to fix it is in Troubleshooting.