Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Provide an iOS API similar to WebViewListener on Android #7260

Open
1 of 3 tasks
hbordersTwitch opened this issue Feb 15, 2024 · 0 comments
Open
1 of 3 tasks
Labels

Comments

@hbordersTwitch
Copy link

hbordersTwitch commented Feb 15, 2024

Description

Android has a WebViewListener to observe WebView health/progress. iOS should have a similar API

Platforms

  • iOS
  • Android
  • Web

Request or proposed solution

On Android, WebViewListener has the following callbacks:

onPageLoaded
onReceivedError
onReceivedHttpError
onPageStarted
onRenderProcessGone

These are all available on iOS via WKNavigationDelegate
onPageLoaded: func webView(WKWebView, didFinish: WKNavigation!)
onReceivedError: func webView(WKWebView, didFailProvisionalNavigation: WKNavigation!, withError: any Error)
onReceivedHttpError: func webView(WKWebView, decidePolicyFor: WKNavigationResponse, decisionHandler: (WKNavigationResponsePolicy) -> Void)
onPageStarted: func webView(WKWebView, didStartProvisionalNavigation: WKNavigation!)
onRenderProcessGone: func webViewWebContentProcessDidTerminate(WKWebView)

Alternatives

CAPWebView.capacitorDidLoad gets called just before capacitor loads the underlying request within the WKWebView, so consumers could create their own WKNavigationDelegate to wrap the existing WebViewDelegationHandler that is set on the WKWebView, and then wrap all of the above methods and delegate into the WebViewDelegationHandler via its conformance to WKNavigationDelegate. This is complex and brittle since it's using API that I assume Capacitor doesn't want consumers to access.

Additional Information

Thanks so much for this project!

@markemer markemer changed the title [WebViewListener for iOS]: Provide an iOS API similar to WebViewListener on Android [Feature]: Provide an iOS API similar to WebViewListener on Android Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant