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

Does this library could be used to substitute AddHostObjectToScript functionality? #22

Open
GitClickOk opened this issue Jun 22, 2024 · 3 comments
Labels
question Further information is requested

Comments

@GitClickOk
Copy link

This is not an issue report, this is a question.

Currently, AddHostObjectToScript is broken for WinUI3. You can see some of these reports here:

https://learn.microsoft.com/en-us/answers/questions/1291522/using-addhostobjecttoscript-in-maui-apps
dotnet/maui#9424
MicrosoftEdge/WebView2Feedback#2754

In my quests, I found this library that looks like that could be used to replace it. Am I correct?

@kekyo
Copy link
Owner

kekyo commented Jun 23, 2024

@GitClickOk Thanks reached out DupeNukem!

From what I can imagine you are thinking, the answer is probably "yes".
I don't understand the details of each issue you've raised, but what we're trying to do with DupeNukem is:

  • In a completely platform-neutral way,
  • Requires only the exchange of "strings" message,
  • Asynchronous RPC communication between JavaScript and .NET on all WebView environments.

In order to achieve this on MAUI, additional work is required because there is a functional deficiency in MAUI's WebView (there is no abstracted interface or implementation for sending messages from JavaScript to the .NET side).

The sample code achieves this, so I recommend trying it out as is (I don't have an iOS environment, so the sample code only implements it for Windows and Android, but I think it should be possible to implement the same thing for iOS WebView).

https://github.com/kekyo/DupeNukem/blob/main/samples/DupeNukem.Maui/Platforms/Windows/JavaScriptMultiplexedWebViewHandler.cs#L26

The reason I started this project in the first place was because I wanted to solve very slow progress of asynchronous support in WebView2 and the headaches I had with other WebView environments every time :)

MicrosoftEdge/WebView2Feedback#75 (comment)

@kekyo kekyo added the question Further information is requested label Jun 23, 2024
@GitClickOk
Copy link
Author

Thanks, @kekyo! I will try it.

@GitClickOk
Copy link
Author

@kekyo, by the way, what about the support of BlazorWebView from Maui?
I'm checking the compatibility of this, I am pretty optimistic about it, but for now I got this issue: #18.

I'm not sure if I should try work directly with BlazorWebView, or the underling WebView (for example, for Windows I can do like WebView2 webView = (WebView2)blazorWebView.Handler.PlatformView;)

Just to be sure that we are in the same page, the BlazorWebView that I am talking is when you create a new ".NET MAUI Blazor Hybrid App" project in Visual Studio 2022. Then, in MainPage.xaml/MainPage.xaml.cs you can see the BlazorWebView there.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants