diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index cf97a1064e84b4..adaf5ed0a731ed 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -2223,6 +2223,7 @@ public abstract interface class com/facebook/react/devsupport/HMRClient : com/fa public abstract fun enable ()V public abstract fun registerBundle (Ljava/lang/String;)V public abstract fun setup (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)V + public abstract fun setup (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZLjava/lang/String;)V } public final class com/facebook/react/devsupport/InspectorFlags { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java index 8278b93d955936..6f9aa23a0d5e88 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java @@ -685,10 +685,12 @@ private void resetCurrentContext(@Nullable ReactContext reactContext) { URL sourceUrl = new URL(getSourceUrl()); String path = sourceUrl.getPath().substring(1); // strip initial slash in path String host = sourceUrl.getHost(); + String scheme = sourceUrl.getProtocol(); int port = sourceUrl.getPort() != -1 ? sourceUrl.getPort() : sourceUrl.getDefaultPort(); mCurrentReactContext .getJSModule(HMRClient.class) - .setup("android", path, host, port, mDevSettings.isHotModuleReplacementEnabled()); + .setup( + "android", path, host, port, mDevSettings.isHotModuleReplacementEnabled(), scheme); } catch (MalformedURLException e) { showNewJavaError(e.getMessage(), e); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/HMRClient.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/HMRClient.java index 7807ef449018a5..4698c3da5593a4 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/HMRClient.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/HMRClient.java @@ -29,6 +29,20 @@ public interface HMRClient extends JavaScriptModule { */ void setup(String platform, String bundleEntry, String host, int port, boolean isEnabled); + /** + * Enable the HMRClient so that the client will receive updates from Metro. + * + * @param platform The platform in which HMR updates will be enabled. Should be "android". + * @param bundleEntry The path to the bundle entry file (e.g. index.ios.bundle). + * @param host The host that the HMRClient should communicate with. + * @param port The port that the HMRClient should communicate with on the host. + * @param isEnabled Whether HMR is enabled initially. + * @param scheme The protocol that the HMRClient should communicate with on the host (defaults to + * http). + */ + void setup( + String platform, String bundleEntry, String host, int port, boolean isEnabled, String scheme); + /** Registers an additional JS bundle with HMRClient. */ void registerBundle(String bundleUrl);