diff --git a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java index 0292783..a0df3af 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java +++ b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java @@ -107,6 +107,7 @@ import javax.annotation.Nullable; @ReactModule(name = RNCWebViewManager.REACT_CLASS) public class RNCWebViewManager extends SimpleViewManager { + public static String activeUrl = null; public static final int COMMAND_GO_BACK = 1; public static final int COMMAND_GO_FORWARD = 2; public static final int COMMAND_RELOAD = 3; @@ -693,6 +694,7 @@ public class RNCWebViewManager extends SimpleViewManager { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { + activeUrl = url; dispatchEvent( view, new TopShouldStartLoadWithRequestEvent( @@ -847,9 +849,18 @@ public class RNCWebViewManager extends SimpleViewManager { @Override public void onProgressChanged(WebView webView, int newProgress) { super.onProgressChanged(webView, newProgress); + final String url = webView.getUrl(); + if ( + url != null + && activeUrl != null + && !url.equals(activeUrl) + ) { + return; + } WritableMap event = Arguments.createMap(); event.putDouble("target", webView.getId()); event.putString("title", webView.getTitle()); + event.putString("url", url); event.putBoolean("canGoBack", webView.canGoBack()); event.putBoolean("canGoForward", webView.canGoForward()); event.putDouble("progress", (float) newProgress / 100); diff --git a/docs/Reference.md b/docs/Reference.md index a41487f..69066f9 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -311,10 +311,6 @@ url Function that is invoked when the `WebView` is loading. -> **_Note_** -> -> On android, You can't get the url property, meaning that `event.nativeEvent.url` will be null. - | Type | Required | | -------- | -------- | | function | No |