Integration guide
Add @getcortexlabs/ota-nativescript to an existing NativeScript 9.1 Webpack 5 application in six steps.
1. Install packages
Install the on-device SDK in your NativeScript app and @getcortexlabs/ota-cli in your release/CI environment:
npm install @getcortexlabs/ota-nativescript
npm install -D @getcortexlabs/ota-cliNote for npm 11+ users
npm 11 disables third-party postinstall scripts by default unless explicitly approved. Verify that hooks/after-prepare/ota-nativescript-config.mjs was created in your app root; if not, install the 1-line hook shim once:
node node_modules/@getcortexlabs/ota-nativescript/hooks/postinstall.mjs .2. Generate an Ed25519 signing keypair
Keep signing private keys outside your app repository (for example ~/.ota-keys locally or a CI secret store). ota-ns keygen refuses to write keys inside src/, app/, App_Resources/ or platforms/ by default:
npx ota-ns keygen --key-id prod-2026 --out-dir ~/.ota-keysCopy the printed publicKeys snippet into ota.config.json.
3. Configure ota.config.json
Create ota.config.json in your app root. Only public keys belong here:
{
"appId": "com.example.myapp",
"channel": "production",
"maxLaunchAttempts": 1,
"publicKeys": {
"prod-2026": "<32-byte-raw-ed25519-public-key-base64>"
},
"platforms": {
"ios": {
"endpoint": "https://updates.example.com/check",
"runtimeContract": "ios-rc-pending"
},
"android": {
"endpoint": "https://updates.example.com/check",
"runtimeContract": "android-rc-pending"
}
}
}When ns prepare or ns build runs, the after-prepare hook validates ota.config.json and embeds it automatically:
- iOS: writes
CortexOtaConfigBase64andCortexOtaRuntimeContractinto the preparedInfo.plist. - Android: writes
assets/cortex_ota_config.jsoninto the APK assets directory.
HTTPS enforcement
Production builds reject plain http:// URLs with OtaError(INSECURE_URL). Only set "allowInsecureHttp": true in local development fixtures talking to 127.0.0.1 or localhost.
4. Call updates.markReady() on the first usable screen
Call updates.markReady() as soon as your root navigation frame and first usable screen have mounted. Never gate markReady() on network reachability, API logins or remote config fetches — otherwise offline launches will look like startup crashes and trigger rollbacks.
// NativeScript-Vue 3 example (App.vue)
import { onMounted } from 'nativescript-vue';
import { updates } from '@getcortexlabs/ota-nativescript';
onMounted(() => {
// 1. Confirm boot synchronously & offline as soon as the screen mounts.
updates.markReady();
// 2. Check and stage in the background for the next cold launch.
void updates.checkAndStage().catch((error) => {
console.warn('[OTA] Background check skipped:', error);
});
});5. Build store binaries & record baselines
Build your store release binaries and capture one compatibility baseline per platform:
# iOS release build + baseline
ns build ios --release --env.production
npx ota-ns fingerprint --platform ios --project . \
--write-baseline ./ota.baseline.ios.json --write-config
# Android signed R8 release build + baseline
ns build android --release --env.production \
--key-store-path ./release.keystore ...
npx ota-ns fingerprint --platform android --project . \
--write-baseline ./ota.baseline.android.json --write-configRebuild once after --write-config updates runtimeContract in ota.config.json so the store binary embeds the exact fingerprinted contract.
Android R8 minification
@getcortexlabs/ota-nativescript ships its own platforms/android/proguard-rules.pro keeping com.getcortexlabs.ota.* and Google Tink Ed25519 classes. Your app's App_Resources/Android/proguard-rules.pro only needs standard NativeScript keep rules (com.tns.**, org.nativescript.**, androidx.**).
6. Pack and verify OTA releases
After making JS, CSS or asset changes:
ns prepare ios --release --env.production
npx ota-ns pack \
--platform ios \
--project . \
--baseline ./ota.baseline.ios.json \
--release-id ota-105 \
--private-key ~/.ota-keys/prod-2026.private.pem \
--key-id prod-2026 \
--out ./dist-ota/ota-105
npx ota-ns verify \
--bundle ./dist-ota/ota-105 \
--config ./ota.config.json \
--baseline ./ota.baseline.ios.jsonIf native inputs drifted since the store binary baseline, ota-ns pack exits non-zero and prints the exact section diff explaining why a new store binary is required.
