Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit eba0db0

Browse files
committed
Update README.md
1 parent c2804da commit eba0db0

File tree

1 file changed

+17
-73
lines changed

1 file changed

+17
-73
lines changed

README.md

Lines changed: 17 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ This plugin provides client-side integration for the [CodePush service](http://c
1414
* [Plugin Configuration](#plugin-configuration-ios)
1515
* [Android Setup](#android-setup)
1616
* [Plugin Installation](#plugin-installation-android)
17+
* [RNPM](#plugin-installation-android---rnpm)
18+
* ["Manual"](#plugin-installation-android---manual)
1719
* [Plugin Configuration](#plugin-configuration-android)
1820
* [Plugin Usage](#plugin-usage)
1921
* [Releasing Updates (JavaScript-only)](#releasing-updates-javascript-only)
@@ -186,73 +188,29 @@ NSURL *jsCodeLocation;
186188
#endif
187189
```
188190

189-
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.
192192
193193
![Deployment list](https://cloud.githubusercontent.com/assets/116461/11601733/13011d5e-9a8a-11e5-9ce2-b100498ffb34.png)
194194
195-
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`.
196-
197-
![Bundle version](https://cloud.githubusercontent.com/assets/116461/12307416/f9b82688-b9f3-11e5-839a-f1c6b4acd093.png)
198-
199195
## Android Setup
200196
201-
In order to accomodate as many developer preferences as possible, the CodePush plugin supports Android setup via two mechanisms:
197+
In order to integrate CodePush into your Android project, perform the following steps:
202198
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.
204204

205205
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.
206206

207-
#### Plugin Installation and Configuration (Android - RNPM)
207+
#### Plugin Installation (Android - RNPM)
208208

209209
1. Run `rnpm link react-native-code-push`
210210

211211
*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.*
212212
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
221-
// bundle location from on each app start
222-
@Override
223-
protected String getJSBundleFile() {
224-
return CodePush.getBundleUrl("index.android.bundle");
225-
}
226-
227-
@Override
228-
protected List<ReactPackage> getPackages() {
229-
// 2. Specify the right deployment key during construction of the CodePush class.
230-
// If you don't already have it, you can run "code-push deployment ls <appName> -k"
231-
// to retrieve your key.
232-
return Arrays.<ReactPackage>asList(
233-
new MainReactPackage(),
234-
// new CodePush() <-- Replace this with the line below
235-
new CodePush("deployment-key-here", this, BuildConfig.DEBUG)
236-
);
237-
}
238-
239-
...
240-
}
241-
```
242-
243-
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 using RNPM! Continue below to the [Plugin Configuration](#plugin-configuration-android) section to complete the setup.
256214

257215
#### Plugin Installation (Android - Manual)
258216

@@ -280,15 +238,14 @@ In order to accomodate as many developer preferences as possible, the CodePush p
280238
...
281239
```
282240

283-
### Plugin Configuration (Android - Manual)
284-
285-
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:
241+
### Plugin Configuration (Android)
286242

287-
1. Update the `MainActivity.java` file to use CodePush via the following changes:
243+
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, update the `MainActivity.java` file to use CodePush via the following changes:
288244

289245
```java
290246
...
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).
292249
import com.microsoft.codepush.react.CodePush;
293250
294251
public class MainActivity extends ReactActivity {
@@ -306,7 +263,8 @@ After installing the plugin and syncing your Android Studio project with Gradle,
306263
// existing packages, specifying the right deployment key. If you don't already
307264
// have it, you can run "code-push deployment ls <appName> -k" to retrieve your key.
308265
return Arrays.<ReactPackage>asList(
309-
new MainReactPackage(),
266+
new MainReactPackage(),
267+
// new CodePush() <-- remove this line if you used RNPM for plugin installation.
310268
new CodePush("deployment-key-here", this, BuildConfig.DEBUG)
311269
);
312270
}
@@ -315,20 +273,6 @@ After installing the plugin and syncing your Android Studio project with Gradle,
315273
}
316274
```
317275

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-
332276
## Plugin Usage
333277

334278
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

Comments
 (0)