-
Notifications
You must be signed in to change notification settings - Fork 50
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
Need to modify the HybridWebView configuration (BEFORE initializing) on iOS/MacCatalyst to fix known base WebView issue ... Any solution? #67
Comments
@Eilon Can you consider inviting other developers help maintain this repo that have contributed already? It seems like you're not giving this repo enough attention. |
I've been working on the official version here: #70 So for that reason my time hasn't been as focused here. Having said that, I'm certainly willing to work with people on features, fixes, and PRs within this repo for features that are good candidates to be in the official version. |
Congratulations on being officially included. Please keep in mind the issue reported in this thread, and if nothing else, please don't break this method without providing us an alternative. Thanks again.
|
There is a problem with the WebView in iOS/MacCatalyst where one must define parameters only on initialization for the ability to play media inline (ie. not go full screen every time you play), autoplay, and configure other media playback parameters.
This is described here:
The two solutions at those locations both don't work for HybridWebView, at least not directly without Reflection for the following reasons:
1) Blazor Fix
The BlazorWebView fix is shown here: dotnet/maui#16013 (comment)
Where the user sets:
BlazorWebViewInitializing="HandleWebViewInitializing"
However, we cannot use this directly as the only event we have in HybridWebView is only run AFTER initialization (which is too late - I tried - config must be set before creation of the WebView and can't be affected after):
2) WebView Solution
The WebView solution is given here: dotnet/maui#4807 (comment) and here: dotnet/maui#11075 by @Redth:
There he suggests overriding the
Microsoft.Maui.Handlers.WebViewHandler.PlatformViewFactory = (handler) =>
function. However, reviewing this in HybridWebView shows it is not so simple. The HybridWebView function is here:However a similar approach doesn't work directly for numerous reasons:
WebViewScriptMessageHandler
,MessageReceived
, orSchemeHandler
this way.Commenting out everything dependent on these breaks the HybridWebView.
3) Reflection Solution (WORKING)
I was just able to get a temporary fix using Reflection and redefining MessageReceived by modifying @Redth's solution approach:
I tested and this does seem to work. I have an inline video autoplaying now.
Long Term Solution?
The simplest solution I can think of would be to just provide us with an
Action<WKWebViewConfiguration> customConfiguration
in iOS/MacCatalyst we can set into the HybridWebView or the Handler somehow before this function is run. It can get utilized inside that existing function like this:Or otherwise I am not sure how you guys would want to fix this.
What do you think @Eilon ? Or @Redth ?
The text was updated successfully, but these errors were encountered: