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
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.
191
192
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.
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 integrate CodePush into your Android project, perform the following steps:
203
198
204
199
### Plugin Installation (Android)
205
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
+
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 usingRNPM! Continue below to the [PluginConfiguration](#plugin-configuration-android) section to complete the setup.
214
+
215
+
#### Plugin Installation (Android - Manual)
216
+
206
217
1. In your `android/settings.gradle` file, make the following additions:
207
218
208
219
```gradle
@@ -227,112 +238,42 @@ In order to integrate CodePush into your Android project, perform the following
*NOTE:These instructions are specific to apps that are usingReactNative 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 usingan 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.*
233
244
234
-
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:
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 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:
242
246
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 {
// 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;
271
252
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
*NOTE:These instructions are specific to apps that are usingReactNative 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 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:
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
// 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
-
}
318
261
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
+
);
320
272
}
321
-
```
322
273
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`.
0 commit comments