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

Commit 17005b4

Browse files
committed
Merge branch 'master' of github.com:Microsoft/react-native-code-push into report-acquisition-status
2 parents 2d5d80f + 818f73b commit 17005b4

File tree

3 files changed

+37
-19
lines changed

3 files changed

+37
-19
lines changed

CodePush.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ - (void)loadBundle
283283
// file (since Chrome wouldn't support it). Otherwise, update
284284
// the current bundle URL to point at the latest update
285285
if ([CodePush isUsingTestConfiguration] || ![_bridge.bundleURL.scheme hasPrefix:@"http"]) {
286-
_bridge.bundleURL = [CodePush bundleURL];
286+
[_bridge setValue:[CodePush bundleURL] forKey:@"bundleURL"];
287287
}
288288

289289
[_bridge reload];
@@ -599,4 +599,4 @@ - (void)savePendingUpdate:(NSString *)packageHash
599599
}
600600
}
601601

602-
@end
602+
@end

README.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# React Native Plugin for CodePush
22

3-
This plugin provides client-side integration for the [CodePush service](https://microsoft.github.io/code-push), allowing you to easily add a dynamic update experience to your React Native app(s).
3+
This plugin provides client-side integration for the [CodePush service](http://codepush.tools), allowing you to easily add a dynamic update experience to your React Native app(s).
44

55
* [How does it work?](#how-does-it-work)
66
* [Supported React Native Platforms](#supported-react-native-platforms)
@@ -38,9 +38,9 @@ In order to ensure that your end users always have a functioning version of your
3838

3939
## Getting Started
4040

41-
Once you've followed the general-purpose ["getting started"](http://microsoft.github.io/code-push/docs/getting-started.html) instructions for setting up your CodePush account, you can start CodePush-ifying your React Native app by running the following command from within your app's root directory:
41+
Once you've followed the general-purpose ["getting started"](http://codepush.tools/docs/getting-started.html) instructions for setting up your CodePush account, you can start CodePush-ifying your React Native app by running the following command from within your app's root directory:
4242

43-
```
43+
```shell
4444
npm install --save react-native-code-push
4545
```
4646

@@ -58,7 +58,7 @@ Once you've acquired the CodePush plugin, you need to integrate it into the Xcod
5858
![Add CodePush to project](https://cloud.githubusercontent.com/assets/516559/10322414/7688748e-6c32-11e5-83c1-00d3e6758df4.png)
5959

6060
3. Select the project node in Xcode and select the "Build Phases" tab of your project configuration.
61-
4. Drag `libCodePush.a` from `Libraries/CodePush.xcodeproj/Products` into the "Link Binary With Libraries" secton of your project's "Build Phases" configuration.
61+
4. Drag `libCodePush.a` from `Libraries/CodePush.xcodeproj/Products` into the "Link Binary With Libraries" section of your project's "Build Phases" configuration.
6262

6363
![Link CodePush during build](https://cloud.githubusercontent.com/assets/516559/10322221/a75ea066-6c31-11e5-9d88-ff6f6a4d6968.png)
6464

@@ -79,34 +79,48 @@ Once your Xcode project has been setup to build/link the CodePush plugin, you ne
7979

8080
1. Open up the `AppDelegate.m` file, and add an import statement for the CodePush headers:
8181

82-
```
82+
```objective-c
8383
#import "CodePush.h"
8484
```
8585

8686
2. Find the following line of code, which loads your JS Bundle from the app binary for production releases:
8787

88-
```
88+
```objective-c
8989
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
9090
```
9191

9292
3. Replace it with this line:
9393

94-
```
94+
```objective-c
9595
jsCodeLocation = [CodePush bundleURL];
9696
```
9797

9898
This change configures your app to always load the most recent version of your app's JS bundle. On the first launch, this will correspond to the file that was compiled with the app. However, after an update has been pushed via CodePush, this will return the location of the most recently installed update.
9999
100100
*NOTE: The `bundleURL` method assumes your app's JS bundle is named `main.jsbundle`. If you have configured your app to use a different file name, simply call the `bundleURLForResource:` method (which assumes you're using the `.jsbundle` extension) or `bundleURLForResource:withExtension:` method instead, in order to overwrite that default behavior*
101101
102+
Typically, you're only going to want to use CodePush to resolve your JS bundle location within release builds, and therefore, we recommend using the `DEBUG` pre-processor macro to dynamically switch between using the packager server and CodePush, depending on whether you are debugging or not. This will make it much simpler to ensure you get the right behavior you want in production, while still being able to use the Chrome Dev Tools, live reload, etc. at debug-time.
103+
104+
```objective-c
105+
NSURL *jsCodeLocation;
106+
107+
#ifdef DEBUG
108+
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
109+
#else
110+
jsCodeLocation = [CodePush bundleURL];
111+
#endif
112+
```
113+
102114
To let the CodePush runtime know which deployment it should query for updates against, perform the following steps:
103115

104116
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>` in the CodePush CLI, 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.
105117

106118
![Deployment list](https://cloud.githubusercontent.com/assets/116461/11601733/13011d5e-9a8a-11e5-9ce2-b100498ffb34.png)
107119

108-
2. In your app's `Info.plist` make sure your `CFBundleShortVersionString` value is a valid [semver](http://semver.org/) version (e.g. 1.0.0 not 1.0)
120+
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 (e.g. 1.0.0 not 1.0)
109121

122+
![Bundle version](https://cloud.githubusercontent.com/assets/116461/12307416/f9b82688-b9f3-11e5-839a-f1c6b4acd093.png)
123+
110124
## Android Setup
111125

112126
In order to integrate CodePush into your Android project, perform the following steps:
@@ -149,7 +163,7 @@ After installing the plugin and syncing your Android Studio project with Gradle,
149163
protected void onCreate(Bundle savedInstanceState) {
150164
...
151165
// 3. Initialize CodePush with your deployment key and an instance of your MainActivity.
152-
CodePush codePush = new CodePush("d73bf5d8-4fbd-4e55-a837-accd328a21ba", this);
166+
CodePush codePush = new CodePush("d73bf5d8-4fbd-4e55-a837-accd328a21ba", this, BuildConfig.DEBUG);
153167
...
154168
mReactInstanceManager = ReactInstanceManager.builder()
155169
.setApplication(getApplication())
@@ -193,13 +207,13 @@ The simplest way to do this is to perform the following in your app's root compo
193207
194208
1. Import the JavaScript module for CodePush:
195209
196-
```
210+
```javascript
197211
import CodePush from "react-native-code-push";
198212
```
199213
200214
2. Call the `sync` method from within the `componentDidMount` lifecycle event, to initiate a background update on each app start:
201215
202-
```
216+
```javascript
203217
CodePush.sync();
204218
```
205219
@@ -211,11 +225,13 @@ Once your app has been configured and distributed to your users, and you've made
211225
212226
1. Execute `react-native bundle` (passing the appropriate parameters, see example below) in order to generate the updated JS bundle for your app. You can place this file wherever you want via the `--bundle-output` flag, since the exact location isn't relevant for CodePush purposes. It's important, however, that you set `--dev false` so that your JS code is optimized appropriately and any "yellow box" warnings won't be displayed.
213227
214-
2. Execute `code-push release <appName> <jsBundleFilePath> <appStoreVersion> --deploymentName <deploymentName>` in order to publish the generated JS bundle to the server. The `<jsBundleFilePath>` parameter should equal the value you provided to the `--bundle-output` flag in step #1. Additionally, the `<appStoreVersion>` parameter should equal the exact app store version (i.e. the semver version end users would see when installing it) you want this CodePush update to target.
228+
2. Execute `code-push release <appName> <jsBundleFilePath> <appStoreVersion> --deploymentName <deploymentName>` in order to publish the generated JS bundle to the server. The `<jsBundleFilePath>` parameter should equal the value you provided to the `--bundle-output` flag in step #1. Additionally, the `<appStoreVersion>` parameter should equal the [**exact app store version**](http://codepush.tools/docs/cli.html#app-store-version-parameter) (i.e. the semver version end users would see when installing it) you want this CodePush update to target.
215229
230+
For more info regarding the `release` command and its parameters, refer to the [CLI documentation](http://codepush.tools/docs/cli.html#releasing-app-updates).
231+
216232
Example Usage:
217233
218-
```
234+
```shell
219235
react-native bundle --platform ios --entry-file index.ios.js --bundle-output codepush.js --dev false
220236
code-push release MyApp codepush.js 1.0.2
221237
```
@@ -234,17 +250,19 @@ If you are using the new React Native [assets system](https://facebook.github.io
234250

235251
2. When calling `react-native bundle`, specify that your assets and JS bundle go into the directory you created in #1, and that you want a non-dev build for your respective platform and entry file. For example, assuming you called this directory "release", you could run the following command:
236252

237-
```
253+
```shell
238254
react-native bundle \
239255
--platform ios \
240256
--entry-file index.ios.js \
241257
--bundle-output ./release/main.jsbundle \
242-
--assets-dest ./release
258+
--assets-dest ./release \
243259
--dev false
244260
```
245261

246-
3. Execute `code-push release`, passing the path to the directory you created in #1 as the "package" 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.
262+
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.
247263

264+
For more info regarding the `release` command and its parameters, refer to the [CLI documentation](http://codepush.tools/docs/cli.html#releasing-app-updates).
265+
248266
Additionally, the CodePush client supports differential updates, so even though you are releasing your JS bundle and assets on every update, your end users will only actually download the files they need. The service handles this automatically so that you can focus on creating awesome apps and we can worry about optimizing end user downloads.
249267

250268
*Note: Releasing assets via CodePush is currently only supported on iOS, and requires that you're using React Native v0.15.0+ and CodePush 1.4.0+. If you are using assets and an older version of the CodePush plugin, you should not release updates via CodePush, because it will break your app's ability to load images from the binary. Please test and release appropriately!*

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-code-push",
3-
"version": "1.5.2-beta",
3+
"version": "1.5.3-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)