You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2025. It is now read-only.
*NOTE: These instructions are specific to apps that are using React Native v0.15.0-v0.17.0. If you are using v0.18.0+, then skip ahead to the next section.*
147
150
148
151
After installing the plugin and syncing your Android Studio project with Gradle, you need to configure your app to consult CodePush for the location of your JS bundle, since it will "take control" of managing the current and all future versions. To do this, perform the following steps:
149
152
@@ -196,6 +199,61 @@ After installing the plugin and syncing your Android Studio project with Gradle,
*NOTE: These instructions are specific to apps that are using React Native v0.18.0+. If you are using v0.15.0-v0.17.0, then refer to the previous section.*
205
+
206
+
After installing the plugin and syncing your Android Studio project with Gradle, you need to configure your app to consult CodePush for the location of your JS bundle, since it will "take control" of managing the current and all future versions. To do this, perform the following steps:
207
+
208
+
1. Update the `MainActivity.java` file to use CodePush via the following changes:
209
+
210
+
```java
211
+
...
212
+
// 1. Import the plugin class
213
+
import com.microsoft.codepush.react.CodePush;
214
+
215
+
public class MainActivity extends ReactActivity {
216
+
// 2. Define a private field to hold the CodePush runtime instance
217
+
private CodePush _codePush;
218
+
219
+
...
220
+
221
+
// 3. Override the getJSBundleFile method in order to let
222
+
// the CodePush runtime determine where to get the JS
// 4. Instantiate an instance of the CodePush runtime, using the right deployment key
232
+
this._codePush = new CodePush("0dsIDongIcoH0mqAmoR0CYb5FhBZNy1w4Bf-l", this, BuildConfig.DEBUG);
233
+
234
+
// 5. Add the CodePush package to the list of existing packages
235
+
return Arrays.<ReactPackage>asList(
236
+
new MainReactPackage(), this._codePush.getReactPackage());
237
+
}
238
+
239
+
...
240
+
}
241
+
```
242
+
243
+
2. Ensure that the `android.defaultConfig.versionName` property in your `android/app/build.gradle` file is set to a semver compliant value (i.e. "1.0.0" not "1.0")
244
+
245
+
```gradle
246
+
android {
247
+
...
248
+
defaultConfig {
249
+
...
250
+
versionName "1.0.0"
251
+
...
252
+
}
253
+
...
254
+
}
255
+
```
256
+
199
257
## Plugin Usage
200
258
201
259
With the CodePush plugin downloaded and linked, and your app asking CodePush where to get the right JS bundle from, the only thing left is to add the necessary code to your app to control the following policies:
@@ -242,7 +300,7 @@ And that's it! for more information regarding the CLI and how the release (or pr
242
300
243
301
## Releasing Updates (JavaScript + images)
244
302
245
-
*Note: Android doesn't currently support deploying assets, so you must use the previous release strategy instead.*
303
+
*Note: Android doesn't currently support deploying assets, so you must use the previous release strategy instead for that platform. We will release Android support as soon as React Native 0.19.0 is released.*
246
304
247
305
If you are using the new React Native [assets system](https://facebook.github.io/react-native/docs/images.html#content), as opposed to loading your images from the network and/or platform-specific mechanisms (e.g. iOS asset catalogs), then you can't simply pass your jsbundle to CodePush as demonstrated above. You **MUST** provide your images as well. To do this, simply use the following workflow:
248
306
@@ -259,6 +317,8 @@ If you are using the new React Native [assets system](https://facebook.github.io
259
317
--dev false
260
318
```
261
319
320
+
*NOTE: The file name that you specify as the value forthe `--bundle-output` parameter must have one of the following extensionsin order to be detected by the plugin: `.js`, `.jsbundle`, `.bundle` (e.g. `main.jsbundle`, `ios.js`). The name of the file isn't relevant, but the extension is used for detectining the bundle within the update contents, and therefore, using any other extension will result in the update failing.*
321
+
262
322
3. Execute `code-push release`, passing the path to the directory you created in #1 as the ["package"](http://codepush.tools/docs/cli.html#package-parameter) parameter, and the [**exact app version**](http://codepush.tools/docs/cli.html#app-store-version-parameter) that this update is targetting as the ["appStoreVersion"](http://codepush.tools/docs/cli.html#app-store-version-parameter) parameter (e.g. `code-push release Foo ./release 1.0.0`). The code-push CLI will automatically handle zipping up the contents for you, so don't worry about handling that yourself.
263
323
264
324
For more info regarding the `release`command and its parameters, refer to the [CLI documentation](http://codepush.tools/docs/cli.html#releasing-app-updates).
0 commit comments