MicrosoftEdge / MicrosoftEdge/WebView2Feedback
Provide AddWebAllowedObject which works like in Windows.UI.Xaml.Controls.WebView
@Lakshmisha-KS is already working on this.
Since Feb 12, 2025.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
Is your feature request related to a problem? Please describe.
At this point we are trying to upgrade a xamarin forms application to Maui. In the app we show a website made by us that needs to be able to talk to the app. We got this working for android but for the windows platform this is currently a blocking issue because WebView2 does not have the AddWebAllowedObject extension method.
Describe the solution you'd like and alternatives you've considered
The solution:
Add a AddWebAllowedObject extension method which works like in the AddWebAllowedObject extension method on Windows.UI.Xaml.Controls.WebView. (Basically the need to call c# code from javascript coming from the webview and retrieving a sync response in the same call)
Alternatives I've tried:
- I tried CoreWebView2.AddHostObjectToScript. This gave a runtime exception in Maui. The proposed fix included adding a C++ library etc... Well I could not get that to work as well.
- Also tried to use this https://gist.github.com/mqudsi/ceb4ecee76eb4c32238a438664783480 but returning promises caused issues.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.