|
@@ -95,19 +95,17 @@ namespace winrt::ReactNativeWebView::implementation {
|
95
|
95
|
if (m_messagingEnabled) {
|
96
|
96
|
auto tag = this->GetValue(winrt::FrameworkElement::TagProperty()).as<winrt::IPropertyValue>().GetInt64();
|
97
|
97
|
m_webBridge = WebViewBridge::WebBridge(tag);
|
98
|
|
- m_message_token = m_webBridge.MessagePostedEvent([this](const int32_t& message) {
|
|
98
|
+ m_message_token = m_webBridge.MessagePostedEvent([this](hstring const& message) {
|
99
|
99
|
this->OnMessagePosted(message);
|
100
|
100
|
});
|
101
|
|
- webView.AddWebAllowedObject(L"__RN_WEBVIEW_JS_BRIDGE", m_webBridge);
|
|
101
|
+ webView.AddWebAllowedObject(L"__REACT_WEB_VIEW_BRIDGE", m_webBridge);
|
102
|
102
|
}
|
103
|
103
|
}
|
104
|
104
|
|
105
|
|
- void ReactWebView::OnMessagePosted(const int32_t& message)
|
|
105
|
+ void ReactWebView::OnMessagePosted(hstring const& message)
|
106
|
106
|
{
|
107
|
107
|
OutputDebugStringW(L"> ReactWebView:OnMessagePosted received \n");
|
108
|
|
-
|
109
|
|
- // TODO: send to RN
|
110
|
|
- // PostMessage(winrt::hstring(args.Value()));
|
|
108
|
+ PostMessage(message);
|
111
|
109
|
}
|
112
|
110
|
|
113
|
111
|
void ReactWebView::OnNavigationCompleted(winrt::WebView const& webView, winrt::WebViewNavigationCompletedEventArgs const& /*args*/) {
|
|
@@ -122,7 +120,7 @@ namespace winrt::ReactNativeWebView::implementation {
|
122
|
120
|
|
123
|
121
|
winrt::hstring windowAlert = L"window.alert = function (msg) {window.external.notify(`{\"type\":\"__alert\",\"message\":\"${msg}\"}`)};";
|
124
|
122
|
if (m_messagingEnabled) {
|
125
|
|
- winrt::hstring postMessage = L"window.ReactNativeWebView = {postMessage: function (data) {__RN_WEBVIEW_JS_BRIDGE.postMessage(String(data))}};";
|
|
123
|
+ winrt::hstring postMessage = L"window.ReactNativeWebView = {postMessage: function (data) {__REACT_WEB_VIEW_BRIDGE.postMessage(String(data))}};";
|
126
|
124
|
webView.InvokeScriptAsync(L"eval", { windowAlert + postMessage });
|
127
|
125
|
}
|
128
|
126
|
else {
|