Could someone provide guidance on how to properly send a message from Typescript to C#? I have been attempting to receive the message in C# using WebView_WebMessageReceived with the code snippet below:
private void WebView_WebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e)
{
var json = e.TryGetWebMessageAsString();
}
In my typescript file, I have tried the following approaches:
window.chrome.webview.postMessage("test");
window.postMessage("test", '*');
window.postMessage({type: 'hello', payload: {}}, '*');
However, it seems that the message is not getting through to C#. Interestingly, the above code functions as expected in plain HTML but not in TypeScript. Any suggestions or insights would be greatly appreciated.