mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
MSIX: implement initial version of notifications library (#1178)
This commit is contained in:
27
src/common/notifications_winrt/BackgroundHandler.cpp
Normal file
27
src/common/notifications_winrt/BackgroundHandler.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user