Skip to content

Commit 0d6f0b4

Browse files
[docs] Add information about how to configure CodePush for applications using ReactInstanceManager.builder() to initialize RN (microsoft#1098)
1 parent eceb261 commit 0d6f0b4

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

docs/setup-android.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ After installing the plugin and syncing your Android Studio project with Gradle,
6666
6767
**For React Native >= v0.29**
6868
69+
If you are integrating Code Push into React Native application please do the following steps:
70+
6971
Update the `MainApplication.java` file to use CodePush via the following changes:
7072
7173
```java
@@ -107,6 +109,40 @@ protected String getJSMainModuleName() {
107109
}
108110
```
109111

112+
If you are integrating React Native into existing native application please do the following steps:
113+
114+
Update `MyReactActivity.java` (it could be named differently in your app) file to use CodePush via the following changes:
115+
116+
```java
117+
...
118+
// 1. Import the plugin class.
119+
import com.microsoft.codepush.react.CodePush;
120+
121+
public class MyReactActivity extends Activity {
122+
private ReactRootView mReactRootView;
123+
private ReactInstanceManager mReactInstanceManager;
124+
125+
@Override
126+
protected void onCreate(Bundle savedInstanceState) {
127+
...
128+
mReactInstanceManager = ReactInstanceManager.builder()
129+
// ...
130+
// Add CodePush package
131+
.addPackage(new CodePush("deployment-key-here", getApplicationContext(), BuildConfig.DEBUG))
132+
// Get the JS Bundle File via Code Push
133+
.setJSBundleFile(CodePush.getJSBundleFile())
134+
// ...
135+
136+
.build();
137+
mReactRootView.startReactApplication(mReactInstanceManager, "MyReactNativeApp", null);
138+
139+
setContentView(mReactRootView);
140+
}
141+
142+
...
143+
}
144+
```
145+
110146
**For React Native v0.19 - v0.28**
111147

112148
Update the `MainActivity.java` file to use CodePush via the following changes:
@@ -236,4 +272,4 @@ new CodePushBuilder("deployment-key-here",getApplicationContext())
236272
.setIsDebugMode(BuildConfig.DEBUG)
237273
.setPublicKeyResourceDescriptor(R.string.CodePushPublicKey)
238274
.build()
239-
```
275+
```

0 commit comments

Comments
 (0)