diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index f04d5e7c..582e23dc 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -11,9 +11,12 @@
-
+
+
+
+
@@ -33,8 +36,8 @@
-
-
+
+
@@ -45,8 +48,8 @@
-
-
+
+
@@ -128,13 +131,13 @@
-
-
+
+
@@ -419,6 +422,7 @@
+
@@ -436,7 +440,7 @@
-
+
@@ -696,16 +700,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -832,10 +826,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -844,8 +870,8 @@
-
-
+
+
diff --git a/README.md b/README.md
index cfa417a8..73645372 100644
--- a/README.md
+++ b/README.md
@@ -40,8 +40,8 @@ class MyInAppBrowser extends InAppBrowser {
}
@override
- void onLoadError(String url, String code, String message) {
- super.onLoadStop(url);
+ void onLoadError(String url, int code, String message) {
+ super.onLoadError(url, code, message);
print("\n\nCan't load $url.. Error: $message\n\n");
}
diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserWebViewClient.java b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserWebViewClient.java
index 315b503f..fc243720 100644
--- a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserWebViewClient.java
+++ b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserWebViewClient.java
@@ -149,8 +149,7 @@ public class InAppBrowserWebViewClient extends WebViewClient {
Map obj = new HashMap<>();
obj.put("url", error.getUrl());
- obj.put("code", 0);
- obj.put("sslerror", error.getPrimaryError());
+ obj.put("code", error.getPrimaryError());
String message;
switch (error.getPrimaryError()) {
case SslError.SSL_DATE_INVALID:
@@ -173,7 +172,7 @@ public class InAppBrowserWebViewClient extends WebViewClient {
message = "The certificate authority is not trusted";
break;
}
- obj.put("message", message);
+ obj.put("message", "SslError: " + message);
InAppBrowserFlutterPlugin.channel.invokeMethod("loaderror", obj);
handler.cancel();
diff --git a/example/lib/main.dart b/example/lib/main.dart
index b151151e..121a1403 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -43,8 +43,8 @@ class MyInAppBrowser extends InAppBrowser {
}
@override
- void onLoadError(String url, String code, String message) {
- super.onLoadStop(url);
+ void onLoadError(String url, int code, String message) {
+ super.onLoadError(url, code, message);
print("\n\nCan't load $url.. Error: $message\n\n");
}
diff --git a/ios/Classes/InAppBrowserWebViewController.swift b/ios/Classes/InAppBrowserWebViewController.swift
index 0910065c..56528d35 100644
--- a/ios/Classes/InAppBrowserWebViewController.swift
+++ b/ios/Classes/InAppBrowserWebViewController.swift
@@ -489,21 +489,21 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
navigationDelegate?.webViewDidFinishLoad(webView)
}
- func webView(_ webView: WKWebView,
- didFailProvisionalNavigation navigation: WKNavigation!,
- withError error: Error) {
- print("webView:didFailProvisionalNavigationWithError - \(Int(error._code)): \(error.localizedDescription)")
- backButton.isEnabled = webView.canGoBack
- forwardButton.isEnabled = webView.canGoForward
- spinner.stopAnimating()
- navigationDelegate?.webView(webView, didFailLoadWithError: error)
- }
+// func webView(_ webView: WKWebView,
+// didFailProvisionalNavigation navigation: WKNavigation!,
+// withError error: Error) {
+// print("webView:didFailProvisionalNavigationWithError - \(Int(error._code)): \(error.localizedDescription)")
+// backButton.isEnabled = webView.canGoBack
+// forwardButton.isEnabled = webView.canGoForward
+// spinner.stopAnimating()
+// navigationDelegate?.webView(webView, didFailLoadWithError: error)
+// }
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
print("webView:didFailNavigationWithError - \(Int(error._code)): \(error.localizedDescription)")
backButton.isEnabled = webView.canGoBack
forwardButton.isEnabled = webView.canGoForward
spinner.stopAnimating()
- navigationDelegate?.webView(webView, didFailLoadWithError: error)
+ navigationDelegate?.webViewDidFailLoadWithError(webView, error: error)
}
}
diff --git a/ios/Classes/SwiftFlutterPlugin.swift b/ios/Classes/SwiftFlutterPlugin.swift
index 8dcab9c0..b6ae5375 100644
--- a/ios/Classes/SwiftFlutterPlugin.swift
+++ b/ios/Classes/SwiftFlutterPlugin.swift
@@ -325,7 +325,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
channel.invokeMethod("loadstop", arguments: ["url": url])
}
- func webView(_ webView: WKWebView, didFailLoadWithError error: Error) {
+ func webViewDidFailLoadWithError(_ webView: WKWebView, error: Error) {
let url: String = webViewController!.currentURL!.absoluteString
let arguments = ["url": url, "code": error._code, "message": error.localizedDescription] as [String : Any]
channel.invokeMethod("loaderror", arguments: arguments)
diff --git a/lib/flutter_inappbrowser.dart b/lib/flutter_inappbrowser.dart
index bc79d5b3..5a76edad 100644
--- a/lib/flutter_inappbrowser.dart
+++ b/lib/flutter_inappbrowser.dart
@@ -44,7 +44,7 @@ class InAppBrowser {
break;
case "loaderror":
String url = call.arguments["url"];
- String code = call.arguments["code"];
+ int code = call.arguments["code"];
String message = call.arguments["message"];
onLoadError(url, code, message);
break;
@@ -212,7 +212,7 @@ class InAppBrowser {
}
///Event fires when the [InAppBrowser] encounters an error loading an [url].
- void onLoadError(String url, String code, String message) {
+ void onLoadError(String url, int code, String message) {
}