Skip to content
CodeOnAir
Docs menu

Native apps (content updates)

Update images, JSON, strings and web content in native Kotlin/Java and Swift apps over the air.

Native Android and iOS apps can't replace their code over the air, but they can replace the content they show. The CodeOnAir content SDKs use the same deployments, keys and CLI as React Native CodePush to ship a folder of files to your app.

What you can and can't update#

Can updateCan't update
Images, icons, bannersKotlin, Java or Swift code
JSON and config files, feature copyNative libraries (.so, frameworks)
Localized strings you load yourselfAndroidManifest.xml, Info.plist, entitlements, permissions
HTML, CSS and JS shown in a WebView / WKWebViewCompiled resources (res/, asset catalogs, storyboards)
Lottie animations, fonts you load from filesAnything that changes what the app does
Store rules
App Store guideline 2.5.2 and Google Play's policy forbid downloading code that changes an app's features. Content releases are data your app already knows how to show. Don't use web content to add features the reviewed app doesn't have.

Install#

build.gradle.kts
dependencies {
    implementation("com.codeonair:content-updates-android:1.0.0")
}
Package.swift (or pod 'CodeOnAirContent')
.package(url: "https://github.com/codeonair/codepush-ios.git", from: "1.0.0")

Use your platform's deployment key from CodePush → Android / iOS. On Android put it in AndroidManifest.xml as <meta-data android:name="com.codeonair.CODEPUSH_DEPLOYMENT_KEY" android:value="cpd_…" />; on iOS add CodePushDeploymentKey to Info.plist. The server defaults to https://app.codeonair.com.

Ship content with the app#

Put the content the app starts with in src/main/assets/codeonair-content/ (Android) or a blue folder reference named codeonair-content (iOS). Until a release is installed, the SDK reads these files; they're never changed or deleted.

Use it#

Kotlin (Application.onCreate)
CodeOnAirContent.init(this)
CodeOnAirContent.addListener { reloadScreens() }   // new content is active
CodeOnAirContent.sync(SyncOptions().apply { installMode = InstallMode.ON_NEXT_RESUME })

val banner: File? = CodeOnAirContent.file("images/banner.png")
val copy: String? = CodeOnAirContent.readText("strings/en.json")
webView.settings.allowFileAccess = true            // off by default since Android 11
webView.loadUrl("file://" + CodeOnAirContent.contentDir() + "/index.html")
Swift (didFinishLaunching)
CodeOnAirContent.start()
CodeOnAirContent.onContentUpdated { _ in reloadScreens() }
CodeOnAirContent.sync(SyncOptions(installMode: .onNextResume))

let banner = CodeOnAirContent.url(for: "images/banner.png")
let copy = CodeOnAirContent.string(for: "strings/en.json")
Install modeWhen new content becomes active
IMMEDIATERight away; your listener reloads the screen. Default for mandatory releases.
ON_NEXT_RESTARTOn the next cold start. Default for optional releases.
ON_NEXT_RESUMEWhen the app comes back from the background, after minimumBackgroundDuration seconds away.
ON_NEXT_SUSPENDWhile the app is in the background (after minimumBackgroundDuration), so the user comes back to it.

No process restart is needed: the SDK switches the active folder and calls your listener.

Release#

Terminal
codeonair-codepush release shop-android ./content 1.2.0 -d "Spring banner"
codeonair-codepush release shop-ios ./content 1.2.x --mandatory

Each release is a complete snapshot of the folder, so relative links (HTML to images) keep working. History, rollouts, patch and rollback work the same as for React Native.

Safety#

  • Every download is checked against its SHA-256 and unpacked into a new folder before it's used; the switch is a single atomic write.
  • New content must be confirmed with notifyReady() (sync() does it for you). If the app is restarted without that, the next launch goes back to the previous content, reports the failure, and skips that release on the device from then on.
  • A new app build (version or build number) starts on its bundled content again.
Stuck? Write to support@codeonair.com with your App ID and what you tried — we reply within a working day.