react-native-ota-client 0.1.1 → 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.
- package/README.md +26 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ import com.facebook.react.ReactApplication
|
|
|
47
47
|
import com.facebook.react.ReactHost
|
|
48
48
|
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
|
|
49
49
|
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
|
|
50
|
+
import com.otasdk.OtaSdkConfig
|
|
50
51
|
import com.otasdk.OtaSdkUpdates
|
|
51
52
|
|
|
52
53
|
class MainApplication : Application(), ReactApplication {
|
|
@@ -61,8 +62,19 @@ class MainApplication : Application(), ReactApplication {
|
|
|
61
62
|
override fun onCreate() {
|
|
62
63
|
super.onCreate()
|
|
63
64
|
val publicKeyPem = resources.openRawResource(R.raw.ota_publisher_public).use { it.readBytes() }
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
OtaSdkUpdates.initialize(
|
|
66
|
+
this,
|
|
67
|
+
OtaSdkConfig(
|
|
68
|
+
serverUrl = BuildConfig.OTA_SERVER_URL,
|
|
69
|
+
runtimeVersion = BuildConfig.OTA_RUNTIME_VERSION,
|
|
70
|
+
channel = BuildConfig.OTA_CHANNEL,
|
|
71
|
+
baseVersion = BuildConfig.OTA_BASE_VERSION,
|
|
72
|
+
publicKeyPem = publicKeyPem,
|
|
73
|
+
allowInsecureHttp = BuildConfig.OTA_ALLOW_INSECURE_HTTP,
|
|
74
|
+
isDebugBuild = BuildConfig.DEBUG,
|
|
75
|
+
appId = BuildConfig.APPLICATION_ID,
|
|
76
|
+
),
|
|
77
|
+
)
|
|
66
78
|
OtaSdkUpdates.beginProcess()
|
|
67
79
|
loadReactNative(this)
|
|
68
80
|
}
|
|
@@ -75,7 +87,7 @@ The `ota_publisher_public` Android raw resource contains only the verification k
|
|
|
75
87
|
|
|
76
88
|
### Flavor-specific configuration
|
|
77
89
|
|
|
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,
|
|
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:
|
|
79
91
|
|
|
80
92
|
```groovy
|
|
81
93
|
android {
|
|
@@ -84,22 +96,30 @@ android {
|
|
|
84
96
|
development {
|
|
85
97
|
dimension "environment"
|
|
86
98
|
applicationIdSuffix ".dev"
|
|
99
|
+
buildConfigField "String", "OTA_SERVER_URL", '"https://dev.example.com"'
|
|
87
100
|
buildConfigField "String", "OTA_RUNTIME_VERSION", '"rn-0.88-android-dev"'
|
|
88
101
|
buildConfigField "String", "OTA_CHANNEL", '"development"'
|
|
89
102
|
buildConfigField "int", "OTA_BASE_VERSION", "0"
|
|
103
|
+
buildConfigField "boolean", "OTA_ALLOW_INSECURE_HTTP", "false"
|
|
90
104
|
}
|
|
91
105
|
staging {
|
|
92
106
|
dimension "environment"
|
|
93
107
|
applicationIdSuffix ".staging"
|
|
108
|
+
buildConfigField "String", "OTA_SERVER_URL", '"https://staging.example.com"'
|
|
94
109
|
buildConfigField "String", "OTA_RUNTIME_VERSION", '"rn-0.88-android-staging"'
|
|
95
110
|
buildConfigField "String", "OTA_CHANNEL", '"staging"'
|
|
96
111
|
buildConfigField "int", "OTA_BASE_VERSION", "0"
|
|
112
|
+
buildConfigField "boolean", "OTA_ALLOW_INSECURE_HTTP", "false"
|
|
97
113
|
}
|
|
98
114
|
}
|
|
99
115
|
}
|
|
100
116
|
```
|
|
101
117
|
|
|
102
|
-
The
|
|
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.
|
|
119
|
+
|
|
120
|
+
### Transport security
|
|
121
|
+
|
|
122
|
+
Use HTTPS for staging and production, with `allowInsecureHttp = false`. Local development may opt in to HTTP only when the URL host is a local development host supported by the SDK (`localhost`, `127.0.0.1`, `::1`, or Android emulator host `10.0.2.2`). The setting is not a general HTTP override. OTA download URLs must also match the configured server origin.
|
|
103
123
|
|
|
104
124
|
## Native startup operations
|
|
105
125
|
|
|
@@ -132,6 +152,8 @@ cd example/android
|
|
|
132
152
|
|
|
133
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.
|
|
134
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).
|
|
156
|
+
|
|
135
157
|
## License
|
|
136
158
|
|
|
137
159
|
MIT
|
package/package.json
CHANGED