Skip to content

Commit 563dbad

Browse files
committed
[android] Support new arch
Credits to @CHOIMINSEOK and @kmsbernard for their PR on the original repo microsoft/react-native-code-push#2792
1 parent ee01e7b commit 563dbad

4 files changed

Lines changed: 209 additions & 69 deletions

File tree

android/app/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
def isNewArchitectureEnabled() {
2+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
3+
}
4+
15
apply plugin: "com.android.library"
26

7+
if (isNewArchitectureEnabled()) {
8+
apply plugin: "com.facebook.react"
9+
}
10+
311
def getExtOrDefault(name) {
412
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["CodePush_" + name]
513
}
@@ -33,6 +41,7 @@ android {
3341
defaultConfig {
3442
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
3543
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
44+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
3645

3746
consumerProguardFiles 'proguard-rules.pro'
3847
}

android/app/src/main/java/com/appzung/codepush/react/CodePush.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.pm.PackageInfo;
55
import android.content.pm.PackageManager;
66

7+
import com.facebook.react.ReactHost;
78
import com.facebook.react.ReactInstanceManager;
89
import com.facebook.react.ReactPackage;
910
import com.facebook.react.bridge.NativeModule;
@@ -43,6 +44,9 @@ public class CodePush implements ReactPackage {
4344
private static String mPublicKey;
4445

4546
private static ReactInstanceHolder mReactInstanceHolder;
47+
48+
private static ReactHostHolder mReactHostHolder;
49+
4650
private static CodePush mCurrentInstance;
4751

4852
public static String getServiceUrl() {
@@ -363,6 +367,18 @@ static ReactInstanceManager getReactInstanceManager() {
363367
return mReactInstanceHolder.getReactInstanceManager();
364368
}
365369

370+
public static void setReactHost(ReactHostHolder reactHostHolder) {
371+
mReactHostHolder = reactHostHolder;
372+
}
373+
374+
static ReactHost getReactHost() {
375+
if (mReactHostHolder == null) {
376+
return null;
377+
}
378+
379+
return mReactHostHolder.getReactHost();
380+
}
381+
366382
@Override
367383
public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
368384
CodePushNativeModule codePushModule = new CodePushNativeModule(reactApplicationContext, this, mUpdateManager, mTelemetryManager, mSettingsManager);

0 commit comments

Comments
 (0)