From 0d6f0b4876bb53c6373291bfcfa3c16b099144fd Mon Sep 17 00:00:00 2001 From: Ruslan Bikkinin Date: Wed, 6 Dec 2017 10:32:23 +0300 Subject: [PATCH] [docs] Add information about how to configure CodePush for applications using ReactInstanceManager.builder() to initialize RN (#1098) --- docs/setup-android.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/docs/setup-android.md b/docs/setup-android.md index 65705b4..8318253 100644 --- a/docs/setup-android.md +++ b/docs/setup-android.md @@ -66,6 +66,8 @@ After installing the plugin and syncing your Android Studio project with Gradle, **For React Native >= v0.29** +If you are integrating Code Push into React Native application please do the following steps: + Update the `MainApplication.java` file to use CodePush via the following changes: ```java @@ -107,6 +109,40 @@ protected String getJSMainModuleName() { } ``` +If you are integrating React Native into existing native application please do the following steps: + +Update `MyReactActivity.java` (it could be named differently in your app) file to use CodePush via the following changes: + +```java +... +// 1. Import the plugin class. +import com.microsoft.codepush.react.CodePush; + +public class MyReactActivity extends Activity { + private ReactRootView mReactRootView; + private ReactInstanceManager mReactInstanceManager; + + @Override + protected void onCreate(Bundle savedInstanceState) { + ... + mReactInstanceManager = ReactInstanceManager.builder() + // ... + // Add CodePush package + .addPackage(new CodePush("deployment-key-here", getApplicationContext(), BuildConfig.DEBUG)) + // Get the JS Bundle File via Code Push + .setJSBundleFile(CodePush.getJSBundleFile()) + // ... + + .build(); + mReactRootView.startReactApplication(mReactInstanceManager, "MyReactNativeApp", null); + + setContentView(mReactRootView); + } + + ... +} +``` + **For React Native v0.19 - v0.28** Update the `MainActivity.java` file to use CodePush via the following changes: @@ -236,4 +272,4 @@ new CodePushBuilder("deployment-key-here",getApplicationContext()) .setIsDebugMode(BuildConfig.DEBUG) .setPublicKeyResourceDescriptor(R.string.CodePushPublicKey) .build() -``` \ No newline at end of file +```