MSIX: implement initial version of notifications library (#1178)

This commit is contained in:
yuyoyuppe
2020-02-04 19:41:00 +03:00
committed by GitHub
parent b41d2d64cb
commit 5089729b18
28 changed files with 794 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#include "pch.h"
#include "BackgroundHandler.h"
#include "BackgroundHandler.g.cpp"
#include "handler_functions.h"
namespace winrt::PowerToysNotifications::implementation
{
using Windows::ApplicationModel::Background::IBackgroundTaskInstance;
using Windows::UI::Notifications::ToastNotificationActionTriggerDetail;
using Windows::Foundation::WwwFormUrlDecoder;
void BackgroundHandler::Run(IBackgroundTaskInstance bti)
{
const auto details = bti.TriggerDetails().try_as<ToastNotificationActionTriggerDetail>();
if (!details)
{
return;
}
WwwFormUrlDecoder decoder{details.Argument()};
const size_t button_id = std::stoi(decoder.GetFirstValueByName(L"button_id").c_str());
auto handler = decoder.GetFirstValueByName(L"handler");
dispatch_to_backround_handler(std::move(handler), std::move(bti), button_id);
}
}