-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Labels
bugSomething isn't workingSomething isn't workingpriority-lowWe have considered this issue and decided that we will not be able to address it in the near future.We have considered this issue and decided that we will not be able to address it in the near future.trackedWe are tracking this work internally.We are tracking this work internally.
Description
Hello
Will we ever be able to pass complex objects into and out of our API's ?
I have follow example:
var dataObj= {nameX: 'max monster',messageX: 'lorem ipsum...'};
async function sendData(){
let res = await chrome.webview.hostObjects.sync.eventForwarder.SendData(dataObj);
console.log(res);
}
In C# API:
using System;
using System.Runtime.InteropServices;
using System.Windows;
using Microsoft.Web.WebView2.Core;
namespace TestWebView2
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
InitializeAsync();
}
async void InitializeAsync()
{
await webView.EnsureCoreWebView2Async(null);
WebView_CoreWebView2Ready();
}
private void WebView_CoreWebView2Ready()
{
webView.CoreWebView2.AddHostObjectToScript("eventForwarder", new EventForwarder());
}
}
public class DataObject
{
public string nameX = "";
public string messageX = "";
public DataObject() { }
}
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public class EventForwarder
{
public string SendData(DataObject data)
{
return "hasCall with parameters: " + data.nameX;
}
}
}
How can I receive the ObjectData on the API side as shown in the example above?
As described above, the example would not work because the following message comes back:
VM6:1 Uncaught (in promise) Error: Schnittstelle nicht unterst�tzt (0x80004002)
at RemoteMessenger.postSyncRequestMessage (<anonymous>:1:10471)
at Function.applyHostFunction (<anonymous>:1:22650)
at Object.apply (<anonymous>:1:15398)
at SendData (test.html:87)
at HTMLDivElement.onclick (test.html:93)
Thank for your answer
Poopooracoocoo, thatsofia and AFatNiBBa
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpriority-lowWe have considered this issue and decided that we will not be able to address it in the near future.We have considered this issue and decided that we will not be able to address it in the near future.trackedWe are tracking this work internally.We are tracking this work internally.