I want to integrate React Native based modules to my existing Android application. This works quite nice so far but I also want to integrate CodePush to deploy updates to my application.
The important point is that the modules should be independent from the specific application because I have multiple different applications that should use those modules. So the modules themselves are independent React Native packages and so they must be separate Code-Push applications (I guess).
Currently such an React Native module (implemented as a Fragment) is working like this:
public class ReactFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
ReactRootView mReactRootView = new ReactRootView(getContext());
ReactInstanceManager mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getActivity().getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(false)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null);
return mReactRootView;
}
}
So following the official CodePush guide I have no idea how to use multiple CodePush projects within the same Android application. However I think that there must be something within my onCreateView
that allows me to inject the CodePush package or at least a custom ReactNativeHost
.