Commit 57e1a86b authored by pichillilorenzo's avatar pichillilorenzo

fixed loading error handling for android and iOS

parent eabcb030
This diff is collapsed.
......@@ -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");
}
......
......@@ -149,8 +149,7 @@ public class InAppBrowserWebViewClient extends WebViewClient {
Map<String, Object> 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();
......
......@@ -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");
}
......
......@@ -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)
}
}
......@@ -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)
......
......@@ -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) {
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment