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.
To let the CodePush runtime know which deployment it should query for updates against, perform the following steps:
190
-
191
-
1. Open your app's `Info.plist` file and add a new entry named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (e.g. the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `code-push deployment ls <appName> -k` in the CodePush CLI (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `Deployment Key` column which corresponds to the deployment you want to use (see below). Note that using the deployment's name (e.g. Staging) will not work. That "friendly name" is intended only for authenticated management usage from the CLI, and not for public consumption within your app.
191
+
To let the CodePush runtime know which deployment it should query for updates against, open your app's `Info.plist` file and add a new entry named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (e.g. the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `code-push deployment ls <appName> -k` in the CodePush CLI (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `Deployment Key` column which corresponds to the deployment you want to use (see below). Note that using the deployment's name (e.g. Staging) will not work. That "friendly name" is intended only for authenticated management usage from the CLI, and not for public consumption within your app.
2. In your app's `Info.plist` make sure your `Bundle versions string, short` (aka `CFBundleShortVersionString`) value is a valid [semver](http://semver.org/) version. Note that if the value provided is missing a patch version, the CodePush server will assume it is `0`, i.e. `1.0` will be treated as `1.0.0`.
In order to accomodate as many developer preferences as possible, the CodePushplugin supportsAndroidsetup via two mechanisms:
197
+
In order to integrate CodePush into your Android project, perform the following steps:
202
198
203
-
1. [**RNPM**](#plugin-installation-and-configuration-android---rnpm) - [React Native Package Manager (RNPM)](https://github.com/rnpm/rnpm) is an awesome tool that provides the simplest installation experience possible for React Native plugins. If you're already using it, or you want to use it, then we recommend this approach.
199
+
### Plugin Installation (Android)
200
+
201
+
In order to accomodate as many developer preferences as possible, the CodePush plugin supports Android installation via two mechanisms:
202
+
203
+
1. [**RNPM**](#plugin-installation-android---rnpm) - [React Native Package Manager (RNPM)](https://github.com/rnpm/rnpm) is an awesome tool that provides the simplest installation experience possible for React Native plugins. If you're already using it, or you want to use it, then we recommend this approach.
204
204
205
205
2. [**"Manual"**](#plugin-installation-android---manual) - If you don't want to depend on any additional tools or are fine with a few extra installation steps (it's a one-time thing), then go with this approach.
206
206
207
-
#### Plugin Installation and Configuration (Android - RNPM)
207
+
#### Plugin Installation (Android - RNPM)
208
208
209
209
1. Run`rnpm link react-native-code-push`
210
210
211
211
*Note:If you don't already have RNPM installed, you can do so by simply running `npm i -g rnpm` and then executing the above command.*
212
212
213
-
2. For Android, RNPM will also attempt to edit your MainActivity.java file to automate adding the CodePush `ReactPackage` to the runtime. However, there are a few tweaks you need to make, as follows:
214
-
215
-
```java
216
-
...
217
-
218
-
public class MainActivity extends ReactActivity {
219
-
// 1. Override the getJSBundleFile method in order to let
220
-
// the CodePush runtime determine where to get the JS
3. Ensure that the `android.defaultConfig.versionName` property in your `android/app/build.gradle` file is set to a semver-compliant value. Note that if the value provided is missing a patch version, the CodePush server will assume it is `0`, i.e. `1.0` will be treated as `1.0.0`.
244
-
245
-
```gradle
246
-
android {
247
-
...
248
-
defaultConfig {
249
-
...
250
-
versionName "1.0.0"
251
-
...
252
-
}
253
-
...
254
-
}
255
-
```
213
+
And that's it for installation usingRNPM! Continue below to the [PluginConfiguration](#plugin-configuration-android) section to complete the setup.
256
214
257
215
#### Plugin Installation (Android - Manual)
258
216
@@ -280,15 +238,14 @@ In order to accomodate as many developer preferences as possible, the CodePush p
280
238
...
281
239
```
282
240
283
-
### Plugin Configuration (Android - Manual)
284
-
285
-
After installing the plugin and syncing your AndroidStudio project with Gradle, you need to configure your app to consult CodePushfor the location of your JS bundle, since it will "take control" of managing the current and all future versions. Todo this, perform the following steps:
241
+
### Plugin Configuration (Android)
286
242
287
-
1. Update the `MainActivity.java` file to use CodePush via the following changes:
243
+
After installing the plugin and syncing your AndroidStudio project with Gradle, you need to configure your app to consult CodePushfor the location of your JS bundle, since it will "take control" of managing the current and all future versions. Todo this, update the `MainActivity.java` file to use CodePush via the following changes:
288
244
289
245
```java
290
246
...
291
-
// 1. Import the plugin class
247
+
// 1. Import the plugin class (if you used RNPM to install the plugin, this
248
+
// should already be done for you automatically so you can skip this step).
292
249
import com.microsoft.codepush.react.CodePush;
293
250
294
251
public class MainActivity extends ReactActivity {
@@ -306,7 +263,8 @@ After installing the plugin and syncing your Android Studio project with Gradle,
306
263
// existing packages, specifying the right deployment key. If you don't already
307
264
// have it, you can run "code-push deployment ls <appName> -k" to retrieve your key.
308
265
return Arrays.<ReactPackage>asList(
309
-
new MainReactPackage(),
266
+
new MainReactPackage(),
267
+
// new CodePush() <-- remove this line if you used RNPM for plugin installation.
310
268
new CodePush("deployment-key-here", this, BuildConfig.DEBUG)
311
269
);
312
270
}
@@ -315,20 +273,6 @@ After installing the plugin and syncing your Android Studio project with Gradle,
315
273
}
316
274
```
317
275
318
-
2. Ensure that the `android.defaultConfig.versionName` property in your `android/app/build.gradle` file is set to a semver-compliant value. Note that if the value provided is missing a patch version, the CodePush server will assume it is `0`, i.e. `1.0` will be treated as `1.0.0`.
319
-
320
-
```gradle
321
-
android {
322
-
...
323
-
defaultConfig {
324
-
...
325
-
versionName "1.0.0"
326
-
...
327
-
}
328
-
...
329
-
}
330
-
```
331
-
332
276
## Plugin Usage
333
277
334
278
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:
0 commit comments