forked from UnigramDev/Unigram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTelegramWebviewProxy.cpp
39 lines (33 loc) · 930 Bytes
/
TelegramWebviewProxy.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "pch.h"
#include "TelegramWebviewProxy.h"
#if __has_include("TelegramWebviewProxy.g.cpp")
#include "TelegramWebviewProxy.g.cpp"
#endif
#include <winrt/Windows.Data.Json.h>
using namespace winrt::Windows::Data::Json;
namespace winrt::Telegram::Native::implementation
{
TelegramWebviewProxy::TelegramWebviewProxy(TelegramWebviewProxyDelegate delegate)
{
_delegate = delegate;
}
void TelegramWebviewProxy::PostEvent(hstring eventName, hstring eventData)
{
_delegate(eventName, eventData);
return;
if (eventName == L"payment_form_submit")
{
try
{
auto json = JsonObject::Parse(eventData);
auto response = json.GetNamedValue(L"credentials");
auto title = json.GetNamedString(L"title", L"");
_delegate(title, response.Stringify());
}
catch (winrt::hresult_error const& ex)
{
_delegate(L"", eventData);
}
}
}
} // namespace winrt::Telegram::Native::implementation