react-native-ota-client 0.1.0 → 0.1.1
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.
- package/README.md +61 -24
- 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
|
|
12
|
+
- A host application with a release-signing setup and a public verification key.
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
@@ -38,33 +38,68 @@ The package also retains the generated-template `multiply()` example; it is not
|
|
|
38
38
|
|
|
39
39
|
## Android configuration
|
|
40
40
|
|
|
41
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
)
|
|
58
|
-
|
|
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.OtaSdkUpdates
|
|
51
|
+
|
|
52
|
+
class MainApplication : Application(), ReactApplication {
|
|
53
|
+
override val reactHost: ReactHost by lazy {
|
|
54
|
+
getDefaultReactHost(
|
|
55
|
+
context = applicationContext,
|
|
56
|
+
packageList = PackageList(this).packages,
|
|
57
|
+
jsBundleFilePath = OtaSdkUpdates.bundlePathForReactHost(),
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
override fun onCreate() {
|
|
62
|
+
super.onCreate()
|
|
63
|
+
val publicKeyPem = resources.openRawResource(R.raw.ota_publisher_public).use { it.readBytes() }
|
|
64
|
+
val config = otaSdkConfigForCurrentVariant(publicKeyPem)
|
|
65
|
+
OtaSdkUpdates.initialize(this, config)
|
|
66
|
+
OtaSdkUpdates.beginProcess()
|
|
67
|
+
loadReactNative(this)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
59
70
|
```
|
|
60
71
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
The
|
|
64
|
-
|
|
65
|
-
###
|
|
72
|
+
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.
|
|
73
|
+
|
|
74
|
+
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.
|
|
75
|
+
|
|
76
|
+
### Flavor-specific configuration
|
|
77
|
+
|
|
78
|
+
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, base version, and public key source set; use distinct runtime versions and channels when environments must receive separate updates. For example:
|
|
79
|
+
|
|
80
|
+
```groovy
|
|
81
|
+
android {
|
|
82
|
+
flavorDimensions "environment"
|
|
83
|
+
productFlavors {
|
|
84
|
+
development {
|
|
85
|
+
dimension "environment"
|
|
86
|
+
applicationIdSuffix ".dev"
|
|
87
|
+
buildConfigField "String", "OTA_RUNTIME_VERSION", '"rn-0.88-android-dev"'
|
|
88
|
+
buildConfigField "String", "OTA_CHANNEL", '"development"'
|
|
89
|
+
buildConfigField "int", "OTA_BASE_VERSION", "0"
|
|
90
|
+
}
|
|
91
|
+
staging {
|
|
92
|
+
dimension "environment"
|
|
93
|
+
applicationIdSuffix ".staging"
|
|
94
|
+
buildConfigField "String", "OTA_RUNTIME_VERSION", '"rn-0.88-android-staging"'
|
|
95
|
+
buildConfigField "String", "OTA_CHANNEL", '"staging"'
|
|
96
|
+
buildConfigField "int", "OTA_BASE_VERSION", "0"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
66
101
|
|
|
67
|
-
|
|
102
|
+
The host application's configuration helper should import `com.otasdk.OtaSdkConfig` and build a fully populated config for the selected variant. The `OTA_*` field names and types must match those read by that helper. 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.
|
|
68
103
|
|
|
69
104
|
## Native startup operations
|
|
70
105
|
|
|
@@ -79,6 +114,8 @@ The SDK autolinks a single `OtaSdkPackage` containing both the sample `OtaSdk` T
|
|
|
79
114
|
|
|
80
115
|
## Development and verification
|
|
81
116
|
|
|
117
|
+
For implementation architecture, behavioral invariants, suggested change workflow, and verification commands, see the [coding-agent implementation guide](agent.md).
|
|
118
|
+
|
|
82
119
|
From the SDK package directory, install the locked Yarn dependencies with the bundled Yarn executable and build its example:
|
|
83
120
|
|
|
84
121
|
```sh
|
|
@@ -93,7 +130,7 @@ cd example/android
|
|
|
93
130
|
./gradlew :react-native-ota-client:testDebugUnitTest
|
|
94
131
|
```
|
|
95
132
|
|
|
96
|
-
Build a development debug app to verify native linking and Metro. OTA activation requires a
|
|
133
|
+
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.
|
|
97
134
|
|
|
98
135
|
## License
|
|
99
136
|
|
package/package.json
CHANGED