dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.26k stars 1.76k forks source link

Maui Android WebView ShouldOverrideUrlLoading is not calling when we set CustomWebViewClient #25626

Open letscodewithkalyan opened 3 weeks ago

letscodewithkalyan commented 3 weeks ago

Description

When we added Custom Mauiwebview client In Android ShouldOverrideUrlLoading is not firing in android

Steps to Reproduce

No response

Link to public reproduction project repository

https://github.com/letscodewithkalyan/MauiWebViewIssue

Version with bug

8.0.91 SR9.1

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

No response

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

jfversluis commented 3 weeks ago

Related to https://github.com/dotnet/maui/issues/11004?

letscodewithkalyan commented 3 weeks ago

@jfversluis "ShouldInterceptRequest" method Is calling fine but "ShouldOverrideUrlLoading" is not firing.

ninachen03 commented 3 weeks ago

This issue has been verified using Visual Studio 17.12.0 Preview 5(9.0.0-rc.2.24503.2 & 8.0.92 & 8.0.3). Can repro this issue at android platform.

mlyga commented 2 weeks ago

ShouldOverrideUrlLoading is firing for me when I go to the other page from the first page that has been loaded initially. But it is not firing for the first loading.

Methods are called in this order after the CustomWebView appears on the page: ... ShouldInterceptRequest ... OnPageFinished ...

Then I go to some other page: ... ShouldInterceptRequest ... ShouldOverrideUrlLoading ... OnPageFinished ...

mattleibow commented 1 week ago

Instead of a new handler, have you tried replacing the mapper? https://github.com/dotnet/maui/blob/c1bb5fd2801b5a65101e97e19295d31296174a83/src/Controls/tests/TestCases.HostApp/Issues/Issue16032.cs#L38-L44

I think that even though you are setting the client in the construction, it is being replaced.

letscodewithkalyan commented 1 week ago

Yeah tried above still exist ShouldInterceptRequest Is calling as expected. Actually issue exist while calling ShouldOverrideUrlLoading.