SDK
Usage & API
The JavaScript surface is small: initialise, sync, and let the crash boundary keep you safe. Everything else is a helper you rarely need.
init(config)
Call once, at module scope, before your component tree renders.
tsx
AeroPush.init({
appKey: 'apk_live_…', // required — from the dashboard
channel: 'production', // default: 'production'
serverUrl: 'https://aeropush.tech', // default; set for a self-hosted server
});| Option | Default | Notes |
|---|---|---|
appKey | — | Required. Your app key. |
channel | production | Which channel to pull from. |
serverUrl | https://aeropush.tech | Origin or …/v1/api base. Set when self-hosting. |
appUpdateTestMode | false | Testing only. Lets store update prompts show on a build you installed directly. Ignored on real store installs, so it’s safe to ship with. |
sync(options)
Checks for a compatible update, downloads and stages it. Safe to call on every launch. Returns a SyncStatus.
tsx
await AeroPush.sync({ installMode: InstallMode.ON_NEXT_RESTART });Install modes
| Mode | Behaviour |
|---|---|
ON_NEXT_RESTART (default) | Download silently; apply on the next cold launch. |
ON_NEXT_RESUME | Download silently; apply when the app next foregrounds. |
IMMEDIATE | Download, then reload the JS runtime right away. |
AeroPushBoundary
Wrap your app so a render crash marks the current bundle as failed, and a successful mount marks it healthy. This is the JS layer of the crash guard.
tsx
import AeroPush, { AeroPushBoundary } from 'react-native-aeropush';
export default function App() {
return (
<AeroPushBoundary>
<YourApp />
</AeroPushBoundary>
);
}Important
Not using the boundary? Call AeroPush.markBundleHealthy() after a successful mount, or the native launch counter rolls the bundle back after 3 launches.Helpers
| Method | Returns | Notes |
|---|---|---|
markBundleHealthy() | Promise<void> | Reset the launch counter — the current bundle is good. |
getCurrentVersion() | Promise<number> | The active OTA bundle version (0 = embedded). |
rollback() | Promise<void> | Manually revert to the previous good bundle. |
restart() | void | Reload the JS runtime now. |
getAppUpdate() | AppUpdateInfo | null | The pending store update prompt, if any. |
subscribeAppUpdate(fn) | () => void | Called whenever that changes. Returns an unsubscribe. |
How the crash guard works
Three independent layers roll a bad bundle back without you writing any recovery code:
- Native launch counter — increments before the bundle loads; reset on a healthy mount. Three launches without a reset triggers a rollback before JS even runs, so it catches native-level crashes too.
- JS global handler — an uncaught JS error marks the bundle failed.
- React error boundary —
AeroPushBoundarycatches render crashes.
Publishing bundles from your terminal or CI? See the CLI reference.