Created
March 22, 2019 22:11
-
-
Save littleV/c41df6018e6360c555b5a4dbf576a08b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UnifiedSDK { | |
private static ReactInstanceManager manager; | |
public static void init(Activity activity) { | |
if (manager == null) { | |
manager = ReactInstanceManager.builder() | |
.setApplication(activity.getApplication()) | |
.setCurrentActivity(activity) | |
.setBundleAssetName("unifiedsdk.bundle") | |
.setJSMainModulePath("index") | |
.addPackage(new MainReactPackage()) | |
.setUseDeveloperSupport(BuildConfig.DEBUG) | |
.setInitialLifecycleState(LifecycleState.RESUMED) | |
.build(); | |
manager.createReactContextInBackground(); | |
} | |
} | |
public static void helloWorld() { | |
if (manager != null) { | |
ReactContext reactContext = manager.getCurrentReactContext(); | |
if (reactContext != null) { | |
CatalystInstance catalystInstance = reactContext.getCatalystInstance(); | |
WritableNativeArray params = new WritableNativeArray(); | |
params.pushString("UnifiedSDK"); | |
catalystInstance.callFunction("CommonInterface", "helloworld", params); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment