Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Flutter Inappwebview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
Flutter Inappwebview
Commits
57e1a86b
Commit
57e1a86b
authored
6 years ago
by
pichillilorenzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed loading error handling for android and iOS
parent
eabcb030
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
42 deletions
+67
-42
.idea/workspace.xml
.idea/workspace.xml
+48
-22
README.md
README.md
+2
-2
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserWebViewClient.java
...renzo/flutter_inappbrowser/InAppBrowserWebViewClient.java
+2
-3
example/lib/main.dart
example/lib/main.dart
+2
-2
ios/Classes/InAppBrowserWebViewController.swift
ios/Classes/InAppBrowserWebViewController.swift
+10
-10
ios/Classes/SwiftFlutterPlugin.swift
ios/Classes/SwiftFlutterPlugin.swift
+1
-1
lib/flutter_inappbrowser.dart
lib/flutter_inappbrowser.dart
+2
-2
No files found.
.idea/workspace.xml
View file @
57e1a86b
This diff is collapsed.
Click to expand it.
README.md
View file @
57e1a86b
...
...
@@ -40,8 +40,8 @@ class MyInAppBrowser extends InAppBrowser {
}
@override
void
onLoadError
(
String
url
,
String
code
,
String
message
)
{
super
.
onLoad
Stop
(
url
);
void
onLoadError
(
String
url
,
int
code
,
String
message
)
{
super
.
onLoad
Error
(
url
,
code
,
message
);
print
(
"
\n\n
Can't load
$url
.. Error:
$message
\n\n
"
);
}
...
...
This diff is collapsed.
Click to expand it.
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserWebViewClient.java
View file @
57e1a86b
...
...
@@ -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
();
...
...
This diff is collapsed.
Click to expand it.
example/lib/main.dart
View file @
57e1a86b
...
...
@@ -43,8 +43,8 @@ class MyInAppBrowser extends InAppBrowser {
}
@override
void
onLoadError
(
String
url
,
String
code
,
String
message
)
{
super
.
onLoad
Stop
(
url
);
void
onLoadError
(
String
url
,
int
code
,
String
message
)
{
super
.
onLoad
Error
(
url
,
code
,
message
);
print
(
"
\n\n
Can't load
$url
.. Error:
$message
\n\n
"
);
}
...
...
This diff is collapsed.
Click to expand it.
ios/Classes/InAppBrowserWebViewController.swift
View file @
57e1a86b
...
...
@@ -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
,
didFailLoadWithE
rror
:
error
)
navigationDelegate
?
.
webView
DidFailLoadWithError
(
webView
,
e
rror
:
error
)
}
}
This diff is collapsed.
Click to expand it.
ios/Classes/SwiftFlutterPlugin.swift
View file @
57e1a86b
...
...
@@ -325,7 +325,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
channel
.
invokeMethod
(
"loadstop"
,
arguments
:
[
"url"
:
url
])
}
func
webView
(
_
webView
:
WKWebView
,
didFailLoadWithError
error
:
Error
)
{
func
webView
DidFailLoadWithError
(
_
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
)
...
...
This diff is collapsed.
Click to expand it.
lib/flutter_inappbrowser.dart
View file @
57e1a86b
...
...
@@ -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
)
{
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment