WebView on iOS using Navigating event fails with obj exception
See original GitHub issueDescription
I have an anchor tag which when clicked, is supposed to call the navigating event, where I inspect the url and do different things and set cancel to true.
Completion handler passed to -[Microsoft_Maui_Platform_MauiWebViewUIDelegate webView:contextMenuConfigurationForElement:completionHandler:] was not called.
<WebView x:Name="WebBrowser" Navigating="WebBrowser_Navigating">
<WebView.Source>
<HtmlWebViewSource>
<HtmlWebViewSource.Html>
<!-- html snipped for brevity, include a tag with a url in the href and some text -->
</HtmlWebViewSource.Html>
</HtmlWebViewSource>
<WebView.Source>
</WebView>
private void WebBrowser_Navigating(object? sender, WebNavigatingEventArgs e)
{
e.Cancel = true;
// business logic here, snipped for brevity
}
Steps to Reproduce
- Create new maui app
- Add webview component with an html anchor tag in the xaml that points to any url
- Hook into the navigating event -
Navigating="WebBrowser_Navigating" - Create callback in the xaml.cs file and in the navigating event callback, set e.Cancel to true
- Deploy to iOS device
- Click the anchor tag in the web view
- Crash
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 13, 14, 15, 16
Did you find any workaround?
No
Relevant log output
Completion handler passed to -[Microsoft_Maui_Platform_MauiWebViewUIDelegate webView:contextMenuConfigurationForElement:completionHandler:] was not called.
Works fine on Windows and Android, no issue.
Issue Analytics
- State:
- Created 10 months ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
WebView Navigated event not firing consistently on iOS
I have a page that has a WebView and an ActivityIndicator. I've wired up event handlers to to the WebView Navigating and Navigated...
Read more >webView(_:didFail:withError:)
This object corresponds to a WKNavigation object that WebKit returned when the load operation began. You use it to track the progress of...
Read more >Issue with observing WKWebView URL changes via ...
I have a WKWebView that presents a Laravel web application. I currently have my ViewController setup to catch URL changes – and it...
Read more >JavaScript Manipulation on iOS Using WebKit
WebKit offers a suite of tools for iOS developers to manipulate JavaScript directly inside a webview in a native app without focusing on...
Read more >WebView and Android back button navigation
Let's explore some solutions to common problems that Android developers often encounter when using WebView, such as back button navigation.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This is because MauiWebViewUIDelegate.SetContextMenuConfiguration may not call completionHandler when no webView.Interactions is available. For workaround you should install WKView.UIDelegate where you going to call completion handler. Something like that:
We’ve moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.