react-native-ota-client 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +71 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -9,7 +9,7 @@ OTA can update JavaScript and bundled assets. Native code, permissions, React Na
9
9
  - Android only; iOS OTA support is not implemented.
10
10
  - React Native 0.88.x, Android New Architecture, and Hermes.
11
11
  - Android min SDK 24.
12
- - A host application with a release-signing/public-key setup and a compatible OTA service.
12
+ - A host application with a release-signing setup and a public verification key.
13
13
 
14
14
  ## Installation
15
15
 
@@ -38,13 +38,33 @@ The package also retains the generated-template `multiply()` example; it is not
38
38
 
39
39
  ## Android configuration
40
40
 
41
- Each host application owns its flavors, IDs, runtime versions, channels, server URL, base version, public verification key, and build-type debug state. Before starting React Native, construct `OtaSdkConfig` with values from the selected app flavor and initialize the SDK:
41
+ Configure the SDK once in the host application's `Application` class. Initialize it in `onCreate()` before calling `loadReactNative()`, and provide the selected bundle path to React Native's host configuration. The SDK's own `BuildConfig.DEBUG` is not the consumer app's build type.
42
42
 
43
43
  ```kotlin
44
- val publicKeyPem = resources.openRawResource(R.raw.ota_publisher_public).use { it.readBytes() }
45
- OtaSdkUpdates.initialize(
46
- this,
47
- OtaSdkConfig(
44
+ import android.app.Application
45
+ import com.facebook.react.PackageList
46
+ import com.facebook.react.ReactApplication
47
+ import com.facebook.react.ReactHost
48
+ import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
49
+ import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
50
+ import com.otasdk.OtaSdkConfig
51
+ import com.otasdk.OtaSdkUpdates
52
+
53
+ class MainApplication : Application(), ReactApplication {
54
+ override val reactHost: ReactHost by lazy {
55
+ getDefaultReactHost(
56
+ context = applicationContext,
57
+ packageList = PackageList(this).packages,
58
+ jsBundleFilePath = OtaSdkUpdates.bundlePathForReactHost(),
59
+ )
60
+ }
61
+
62
+ override fun onCreate() {
63
+ super.onCreate()
64
+ val publicKeyPem = resources.openRawResource(R.raw.ota_publisher_public).use { it.readBytes() }
65
+ OtaSdkUpdates.initialize(
66
+ this,
67
+ OtaSdkConfig(
48
68
  serverUrl = BuildConfig.OTA_SERVER_URL,
49
69
  runtimeVersion = BuildConfig.OTA_RUNTIME_VERSION,
50
70
  channel = BuildConfig.OTA_CHANNEL,
@@ -53,14 +73,49 @@ OtaSdkUpdates.initialize(
53
73
  allowInsecureHttp = BuildConfig.OTA_ALLOW_INSECURE_HTTP,
54
74
  isDebugBuild = BuildConfig.DEBUG,
55
75
  appId = BuildConfig.APPLICATION_ID,
56
- ),
57
- )
58
- OtaSdkUpdates.beginProcess()
76
+ ),
77
+ )
78
+ OtaSdkUpdates.beginProcess()
79
+ loadReactNative(this)
80
+ }
81
+ }
59
82
  ```
60
83
 
61
- Do this in the host app's `Application.onCreate()` before `loadReactNative()`. Pass `OtaSdkUpdates.bundlePathForReactHost()` to React Native's host configuration so an activated OTA bundle is selected before the JS runtime starts. The SDK's own `BuildConfig.DEBUG` is not the consumer app's build type.
84
+ Call `beginProcess()` before `loadReactNative()` so the selected bundle is ready when the JS runtime starts. `bundlePathForReactHost()` returns `null` when the APK bundle should be used.
85
+
86
+ The `ota_publisher_public` Android raw resource contains only the verification key. It may be placed in `src/main/res/raw/` when shared by all variants, or in a flavor-specific source set such as `src/development/res/raw/` when variants use different keys. Never package the publisher's signing private key in the app or SDK.
87
+
88
+ ### Flavor-specific configuration
89
+
90
+ Define each environment as an Android `productFlavor` and provide the SDK values as flavor-specific `BuildConfig` fields. The flavor controls the app ID, runtime version, channel, server URL, base version, public verification key, and build-type debug state; use distinct runtime versions and channels when environments must receive separate updates. For example:
91
+
92
+ ```groovy
93
+ android {
94
+ flavorDimensions "environment"
95
+ productFlavors {
96
+ development {
97
+ dimension "environment"
98
+ applicationIdSuffix ".dev"
99
+ buildConfigField "String", "OTA_SERVER_URL", '"https://dev.example.com"'
100
+ buildConfigField "String", "OTA_RUNTIME_VERSION", '"rn-0.88-android-dev"'
101
+ buildConfigField "String", "OTA_CHANNEL", '"development"'
102
+ buildConfigField "int", "OTA_BASE_VERSION", "0"
103
+ buildConfigField "boolean", "OTA_ALLOW_INSECURE_HTTP", "false"
104
+ }
105
+ staging {
106
+ dimension "environment"
107
+ applicationIdSuffix ".staging"
108
+ buildConfigField "String", "OTA_SERVER_URL", '"https://staging.example.com"'
109
+ buildConfigField "String", "OTA_RUNTIME_VERSION", '"rn-0.88-android-staging"'
110
+ buildConfigField "String", "OTA_CHANNEL", '"staging"'
111
+ buildConfigField "int", "OTA_BASE_VERSION", "0"
112
+ buildConfigField "boolean", "OTA_ALLOW_INSECURE_HTTP", "false"
113
+ }
114
+ }
115
+ }
116
+ ```
62
117
 
63
- The public key resource contains only the verification key. Never package the publisher's signing private key in the app or SDK.
118
+ The `OTA_*` field names and types must match those read in `MainApplication.kt`. Set `react.debuggableVariants` for every flavor's debug variants (for example, `developmentDebug` and `stagingDebug`) so React Native uses Metro for those builds. `BuildConfig.DEBUG` is supplied by the selected build type, while `BuildConfig.APPLICATION_ID` includes any flavor suffix.
64
119
 
65
120
  ### Transport security
66
121
 
@@ -79,6 +134,8 @@ The SDK autolinks a single `OtaSdkPackage` containing both the sample `OtaSdk` T
79
134
 
80
135
  ## Development and verification
81
136
 
137
+ For implementation architecture, behavioral invariants, suggested change workflow, and verification commands, see the [coding-agent implementation guide](agent.md).
138
+
82
139
  From the SDK package directory, install the locked Yarn dependencies with the bundled Yarn executable and build its example:
83
140
 
84
141
  ```sh
@@ -93,7 +150,9 @@ cd example/android
93
150
  ./gradlew :react-native-ota-client:testDebugUnitTest
94
151
  ```
95
152
 
96
- Build a development debug app to verify native linking and Metro. OTA activation requires a development release APK. The compatible FastAPI service and its deployment instructions are maintained in the standalone [`react-native-ota-server`](https://github.com/arjunnarangali/react-native-ota-server) repository. Configure the host app with its API origin, Android app ID, runtime version, channel, and public verification key; see that repository's README and API docs for the server contract.
153
+ Build a development debug app to verify native linking and Metro. OTA activation requires a release APK; debug builds use Metro and report activation as disabled.
154
+
155
+ For the companion OTA server API and release contract, see the [`react-native-ota-server` GitHub repository](https://github.com/arjunnarangali/react-native-ota-server).
97
156
 
98
157
  ## License
99
158
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ota-client",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Android over-the-air JavaScript updates for React Native applications",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",