Skip to content

Commit 28dd8a9

Browse files
committed
Merge pull request #265 from Microsoft/update-docs
Update docs
2 parents 8770f20 + 2f63960 commit 28dd8a9

File tree

2 files changed

+50
-109
lines changed

2 files changed

+50
-109
lines changed

README.md

+49-108
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ 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-
* [Plugin Configuration (React Native < v0.18.0)](#plugin-configuration-android---react-native--v0180)
18-
* [Plugin Configuration (React Native 0.18.0+)](#plugin-configuration-android---react-native-v0180)
17+
* [RNPM](#plugin-installation-android---rnpm)
18+
* ["Manual"](#plugin-installation-android---manual)
19+
* [Plugin Configuration](#plugin-configuration-android)
1920
* [Plugin Usage](#plugin-usage)
2021
* [Releasing Updates (JavaScript-only)](#releasing-updates-javascript-only)
2122
* [Releasing Updates (JavaScript + images)](#releasing-updates-javascript--images)
@@ -187,22 +188,32 @@ NSURL *jsCodeLocation;
187188
#endif
188189
```
189190

190-
To let the CodePush runtime know which deployment it should query for updates against, perform the following steps:
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.
191192
192-
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.
193-
194-
![Deployment list](https://cloud.githubusercontent.com/assets/116461/11601733/13011d5e-9a8a-11e5-9ce2-b100498ffb34.png)
195-
196-
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`.
197-
198-
![Bundle version](https://cloud.githubusercontent.com/assets/116461/12307416/f9b82688-b9f3-11e5-839a-f1c6b4acd093.png)
193+
![Deployment list](https://cloud.githubusercontent.com/assets/116461/11601733/13011d5e-9a8a-11e5-9ce2-b100498ffb34.png)
199194
200195
## Android Setup
201196
202197
In order to integrate CodePush into your Android project, perform the following steps:
203198
204199
### Plugin Installation (Android)
205200
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+
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+
207+
#### Plugin Installation (Android - RNPM)
208+
209+
1. Run `rnpm link react-native-code-push`
210+
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+
213+
And that's it for installation using RNPM! Continue below to the [Plugin Configuration](#plugin-configuration-android) section to complete the setup.
214+
215+
#### Plugin Installation (Android - Manual)
216+
206217
1. In your `android/settings.gradle` file, make the following additions:
207218

208219
```gradle
@@ -227,112 +238,42 @@ In order to integrate CodePush into your Android project, perform the following
227238
...
228239
```
229240

230-
### Plugin Configuration (Android - React Native < v0.18.0)
241+
### Plugin Configuration (Android)
231242

232-
*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.*
243+
*Note: If you are using an older version (<=1.9.0-beta) of the CodePush plugin, please refer to [these docs](https://github.com/Microsoft/react-native-code-push/tree/e717eb024fe9d1810ac21c40c097f7bc165ea5f1#plugin-configuration-android---react-native--v0180) instead.*
233244

234-
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:
235-
236-
1. Update the `MainActivity.java` file to use CodePush via the following changes:
237-
238-
```java
239-
...
240-
// 1. Import the plugin class
241-
import com.microsoft.codepush.react.CodePush;
245+
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:
242246

243-
// 2. Optional: extend FragmentActivity if you intend to show a dialog prompting users about updates.
244-
// If you do this, make sure to also add "import android.support.v4.app.FragmentActivity" below #1.
245-
public class MainActivity extends FragmentActivity implements DefaultHardwareBackBtnHandler {
246-
...
247-
248-
@Override
249-
protected void onCreate(Bundle savedInstanceState) {
250-
...
251-
// 3. Initialize CodePush with your deployment key and an instance of your MainActivity. If you don't
252-
// already have it, you can run "code-push deployment ls <appName> -k" in order to retrieve your key.
253-
CodePush codePush = new CodePush("d73bf5d8-4fbd-4e55-a837-accd328a21ba", this, BuildConfig.DEBUG);
254-
...
255-
mReactInstanceManager = ReactInstanceManager.builder()
256-
.setApplication(getApplication())
257-
...
258-
// 4. DELETE THIS LINE --> .setBundleAssetName("index.android.bundle")
259-
260-
// 5. Let CodePush determine which location to load the most updated bundle from.
261-
// If there is no updated bundle from CodePush, the location will be the assets
262-
// folder with the name of the bundle passed in, e.g. index.android.bundle
263-
.setJSBundleFile(codePush.getBundleUrl("index.android.bundle"))
264-
265-
// 6. Expose the CodePush module to JavaScript.
266-
.addPackage(codePush.getReactPackage())
267-
...
268-
}
269-
}
270-
```
247+
```java
248+
...
249+
// 1. Import the plugin class (if you used RNPM to install the plugin, this
250+
// should already be done for you automatically so you can skip this step).
251+
import com.microsoft.codepush.react.CodePush;
271252
272-
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`.
273-
274-
```gradle
275-
android {
276-
...
277-
defaultConfig {
278-
...
279-
versionName "1.0.0"
280-
...
281-
}
282-
...
253+
public class MainActivity extends ReactActivity {
254+
// 2. Override the getJSBundleFile method in order to let
255+
// the CodePush runtime determine where to get the JS
256+
// bundle location from on each app start
257+
@Override
258+
protected String getJSBundleFile() {
259+
return CodePush.getBundleUrl();
283260
}
284-
```
285-
286-
### Plugin Configuration (Android - React Native v0.18.0+)
287-
288-
*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.*
289-
290-
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:
291-
292-
1. Update the `MainActivity.java` file to use CodePush via the following changes:
293-
294-
```java
295-
...
296-
// 1. Import the plugin class
297-
import com.microsoft.codepush.react.CodePush;
298-
299-
public class MainActivity extends ReactActivity {
300-
// 2. Override the getJSBundleFile method in order to let
301-
// the CodePush runtime determine where to get the JS
302-
// bundle location from on each app start
303-
@Override
304-
protected String getJSBundleFile() {
305-
return this._codePush.getBundleUrl("index.android.bundle");
306-
}
307-
308-
@Override
309-
protected List<ReactPackage> getPackages() {
310-
// 3. Instantiate an instance of the CodePush runtime and add it to the list of
311-
// existing packages, specifying the right deployment key. If you don't already
312-
// have it, you can run "code-push deployment ls <appName> -k" to retrieve your key.
313-
return Arrays.<ReactPackage>asList(
314-
new MainReactPackage(),
315-
new CodePush("deployment-key-here", this, BuildConfig.DEBUG)
316-
);
317-
}
318261
319-
...
262+
@Override
263+
protected List<ReactPackage> getPackages() {
264+
// 3. Instantiate an instance of the CodePush runtime and add it to the list of
265+
// existing packages, specifying the right deployment key. If you don't already
266+
// have it, you can run "code-push deployment ls <appName> -k" to retrieve your key.
267+
return Arrays.<ReactPackage>asList(
268+
new MainReactPackage(),
269+
// new CodePush() <-- remove this generated line if you used RNPM for plugin installation.
270+
new CodePush("deployment-key-here", this, BuildConfig.DEBUG)
271+
);
320272
}
321-
```
322273
323-
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`.
324-
325-
```gradle
326-
android {
327-
...
328-
defaultConfig {
329-
...
330-
versionName "1.0.0"
331-
...
332-
}
333-
...
334-
}
335-
```
274+
...
275+
}
276+
```
336277

337278
## Plugin Usage
338279

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-code-push",
3-
"version": "1.9.0-beta",
3+
"version": "1.10.0-beta",
44
"description": "React Native plugin for the CodePush service",
55
"main": "CodePush.js",
66
"homepage": "https://microsoft.github.io/code-push",

0 commit comments

Comments
 (0)