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

Let WebView receive messages from the WebSite #14325

Closed
SF-Simon opened this issue Mar 31, 2023 · 7 comments
Closed

Let WebView receive messages from the WebSite #14325

SF-Simon opened this issue Mar 31, 2023 · 7 comments
Labels
area-controls-webview WebView proposal/open s/needs-attention Issue has more information and needs another look

Comments

@SF-Simon
Copy link

Description

This is a very important interaction requirement, so that we can execute some scripts from the web and notify C# to execute certain processes. We can also receive data from the Web and store it in the current database.

Public API Changes

Should just send a command name and an object like WKWebView?

The actual running code should still be completed by C# itself, which is the safest.
Just inject a JS script to implement the command function before the webpage initialization is completed.

https://developer.apple.com/documentation/webkit/wkscriptmessagehandler

Intended Use-Case

For example, send some events from the WebEditor to the MAUI client, and then the MAUI client responds to the events.

@Eilon
Copy link
Member

Eilon commented Mar 31, 2023

Hi, check out the HybridWebView prototype I wrote a while ago. I think it handles the exact scenario that you are looking for.

@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Mar 31, 2023
@Eilon
Copy link
Member

Eilon commented Mar 31, 2023

Also, even if it isn't exactly what you need, if you do check it out, I'd love to hear your feedback. And also it might have sample code that could be useful to you in the meantime if you need to build something custom.

@SF-Simon
Copy link
Author

Also, even if it isn't exactly what you need, if you do check it out, I'd love to hear your feedback. And also it might have sample code that could be useful to you in the meantime if you need to build something custom.

Hello, @Eilon

I think it should be very suitable for me.

I've seen this project at Leuan Walker, but I didn't know it was yours. I think his simplified version is also very informative.
Eilon/MauiHybridWebView#1

So...When can I use it? Or is it suitable for me to add it to my project now?

Can this represent the official development direction of MAUI? Or is it a try?

Thank you for your time. You have saved me time more than once. thank you very much.

@rachelkang rachelkang added the s/needs-attention Issue has more information and needs another look label Apr 4, 2023
@rachelkang
Copy link
Member

@Eilon

@Eilon
Copy link
Member

Eilon commented Apr 10, 2023

Hi @SF-Simon , the HybridWebView that I showed is currently only an experiment, but it's something we're considering adding to the product in the future. As such, you can certainly use it right now, but it is not officially supported, and has not been extensively tested. One way to look at it is that if you need some functionality like what it provides, it should serve as an example of how you can make progress in your app until there is an official solution for it.

@mattleibow
Copy link
Member

Duplicate of #6446

@mattleibow mattleibow marked this as a duplicate of #6446 Nov 3, 2023
@mattleibow
Copy link
Member

Closing this one as the other one is much more active. See you all on that one!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-webview WebView proposal/open s/needs-attention Issue has more information and needs another look
Projects
None yet
Development

No branches or pull requests

4 participants