For my Android app, I need to be able to dynamically update the Bundle at runtime and use the pre-saved bundle in my Assets as a fall back. I have failed to find any informa
1.download bundle file(s) and manage the path(s).
2.new a ReactNativeHost in your Application:
public String mBundleFilePath = "";
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List getPackages() {
return Arrays.asList(new MainReactPackage(), new MyReactPackage());
}
@Override
protected String getJSBundleFile() {
return mBundleFilePath;
}
};
3.before starting a ReactActivity, assign the path of ur bundle file to variable: mBundleFilePath.
public class ReactNativeActivity extends ReactActivity {
public static void launchSelf(...) {
MyApplication.getInstance().mBundleFilePath = path;
COMPONENT_NAME = ...;
Intent intent = new Intent(activity,ReactNativeActivity.class);
activity.startActivity(..);
}
...
}
source code:
com.facebook.react.ReactNativeHost#createReactInstanceManager
com.facebook.react.ReactInstanceManager.Builder#setJSBundleFile
com.facebook.react.cxxbridge.JSBundleLoader#createFileLoader
...
may it help u : )