Bare React Native OTA Updates Setup
Wire over-the-air updates into a bare React Native app: AppDelegate on iOS, MainApplication on Android (both templates), and the channel SDK key.
Two edits per platform: point React Native at the OTA bundle, and add the channel key from ota init. The same key goes in both platforms.
Android
Return the OTA bundle from MainApplication
This is what makes updates take effect — React Native asks the host for a bundle path at start-up, and the SDK answers with the newest healthy downloaded bundle. Which edit you need depends on which template your RN version generated.
android/app/src/main/java/…/MainApplication.kt
import com.otaupdate.OtaUpdate
override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getJSMainModuleName(): String = "index"
override fun getJSBundleFile(): String? =
OtaUpdate.getJSBundleFile(applicationContext) // <- add this
}Add the key
android/app/src/main/res/values/strings.xml
<string name="ota_deployment_key" translatable="false">ota_live_xxxxxxxxxxxxxxxxxxxxxxxx</string>That's it — the SDK already knows which server to talk to.
iOS
Install pods
terminal
cd ios && pod installReturn the OTA bundle from your AppDelegate
ios/AppDelegate.swift
import OtaUpdate
override func bundleURL() -> URL? {
#if DEBUG
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
return OtaUpdate.bundleURL() // was Bundle.main.url(forResource:…)
#endif
}Add the key
ios/<YourApp>/Info.plist
<key>OtaDeploymentKey</key>
<string>ota_live_xxxxxxxxxxxxxxxxxxxxxxxx</string>Same key as Android. The device reports its own platform on every check.
Building staging and production from one project
Give each build variant its own
strings.xml / Info.plist value (an Android product flavour or build type, an Xcode configuration) and paste the matching channel key into each. The channel then travels with the binary, so a staging build can never take production updates.