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

Commit 9123f9b

Browse files
[Docs] Update "setup android" docs with TOC and RNN apps setup instructions (#1122)
* Update "setup android" docs with TOC and RNN apps setup instructions
1 parent aa14c1e commit 9123f9b

File tree

1 file changed

+87
-5
lines changed

1 file changed

+87
-5
lines changed

docs/setup-android.md

Lines changed: 87 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
## Android Setup
22

3-
In order to integrate CodePush into your Android project, perform the following steps:
3+
* [Plugin Installation (Android)](#plugin-installation-android)
4+
* [Plugin Installation (Android - RNPM)](#plugin-installation-android---rnpm)
5+
* [Plugin Installation (Android - Manual)](#plugin-installation-android---manual)
6+
* [Plugin Configuration (Android)](#plugin-configuration-android)
7+
* [For React Native >= v0.29](#for-react-native--v029)
8+
* [For newly created React Native application](#for-newly-created-react-native-application)
9+
* [For existing native application](#for-existing-native-application)
10+
* [For React Native v0.19 - v0.28](#for-react-native-v019---v028)
11+
* [Background React Instances](#background-react-instances)
12+
* [For React Native >= v0.29 (Background React Instances)](#for-react-native--v029-background-react-instances)
13+
* [For React Native v0.19 - v0.28 (Background React Instances)](#for-react-native-v019---v028-background-react-instances)
14+
* [WIX React Native Navigation applications (ver 1.x)](#wix-react-native-navigation-applications)
15+
* [Code Signing setup](#code-signing-setup)
16+
17+
In order to integrate CodePush into your Android project, please perform the following steps:
418

519
### Plugin Installation (Android)
620

@@ -64,7 +78,9 @@ And that's it for installation using RNPM! Continue below to the [Plugin Configu
6478
6579
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:
6680
67-
**For React Native >= v0.29**
81+
#### For React Native >= v0.29
82+
83+
##### For newly created React Native application
6884
6985
If you are integrating Code Push into React Native application please do the following steps:
7086
@@ -109,6 +125,8 @@ protected String getJSMainModuleName() {
109125
}
110126
```
111127

128+
##### For existing native application
129+
112130
If you are integrating React Native into existing native application please do the following steps:
113131

114132
Update `MyReactActivity.java` (it could be named differently in your app) file to use CodePush via the following changes:
@@ -143,7 +161,7 @@ public class MyReactActivity extends Activity {
143161
}
144162
```
145163

146-
**For React Native v0.19 - v0.28**
164+
#### For React Native v0.19 - v0.28
147165

148166
Update the `MainActivity.java` file to use CodePush via the following changes:
149167

@@ -183,7 +201,7 @@ public class MainActivity extends ReactActivity {
183201

184202
In order to update/restart your React Native instance, CodePush must be configured with a `ReactInstanceHolder` before attempting to restart an instance in the background. This is usually done in your `Application` implementation.
185203

186-
**For React Native >= v0.29**
204+
##### For React Native >= v0.29 (Background React Instances)
187205

188206
Update the `MainApplication.java` file to use CodePush via the following changes:
189207

@@ -210,7 +228,7 @@ public class MainApplication extends Application implements ReactApplication {
210228
}
211229
```
212230

213-
**For React Native v0.19 - v0.28**
231+
##### For React Native v0.19 - v0.28 (Background React Instances)
214232

215233
Before v0.29, React Native did not provide a `ReactNativeHost` abstraction. If you're launching a background instance, you'll likely have built your own, which should now implement `ReactInstanceHolder`. Once that's done:
216234

@@ -230,6 +248,70 @@ public class MainApplication extends Application {
230248

231249
In order to effectively make use of the `Staging` and `Production` deployments that were created along with your CodePush app, refer to the [multi-deployment testing](../README.md#multi-deployment-testing) docs below before actually moving your app's usage of CodePush into production.
232250

251+
#### WIX React Native Navigation applications
252+
253+
If you are using [WIX React Native Navigation **version 1.x**](https://github.com/wix/react-native-navigation) based application, please do the following steps to integrate CodePush:
254+
255+
1. No need to change `MainActivity.java` file, so if you are integrating CodePush to newly created RNN application it might be looking like this:
256+
257+
```java
258+
import com.facebook.react.ReactActivity;
259+
import com.reactnativenavigation.controllers.SplashActivity;
260+
261+
public class MainActivity extends SplashActivity {
262+
263+
}
264+
```
265+
266+
2. Update the `MainApplication.java` file to use CodePush via the following changes:
267+
268+
```java
269+
// ...
270+
import com.facebook.react.ReactInstanceManager;
271+
272+
// Add CodePush imports
273+
import com.microsoft.codepush.react.ReactInstanceHolder;
274+
import com.microsoft.codepush.react.CodePush;
275+
276+
public class MainApplication extends NavigationApplication implements ReactInstanceHolder {
277+
278+
@Override
279+
public boolean isDebug() {
280+
// Make sure you are using BuildConfig from your own application
281+
return BuildConfig.DEBUG;
282+
}
283+
284+
protected List<ReactPackage> getPackages() {
285+
// Add additional packages you require here
286+
return Arrays.<ReactPackage>asList(
287+
new CodePush("deployment-key-here", getApplicationContext(), BuildConfig.DEBUG)
288+
);
289+
}
290+
291+
@Override
292+
public List<ReactPackage> createAdditionalReactPackages() {
293+
return getPackages();
294+
}
295+
296+
@Override
297+
public String getJSBundleFile() {
298+
// Override default getJSBundleFile method with the one CodePush is providing
299+
return CodePush.getJSBundleFile();
300+
}
301+
302+
@Override
303+
public String getJSMainModuleName() {
304+
return "index";
305+
}
306+
307+
@Override
308+
public ReactInstanceManager getReactInstanceManager() {
309+
// CodePush must be told how to find React Native instance
310+
return getReactNativeHost().getReactInstanceManager();
311+
}
312+
}
313+
```
314+
233315
#### Code Signing setup
234316

235317
Starting with CLI version **2.1.0** you can self sign bundles during release and verify its signature before installation of update. For more info about Code Signing please refer to [relevant code-push documentation section](https://github.com/Microsoft/code-push/tree/master/cli#code-signing). In order to use Public Key for Code Signing you need to do following steps:

0 commit comments

Comments
 (0)