Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7119200
First iteration
pmpurifoy Jun 20, 2022
4765ea2
Fix formatting issues
pmpurifoy Jun 20, 2022
30a4376
Remove all references to toast
pmpurifoy Jun 20, 2022
40bd764
Add ProgressBar
pmpurifoy Jun 21, 2022
8668d3a
Remove getters and other nits
pmpurifoy Jun 21, 2022
1545006
Add XML outputs for all examples
pmpurifoy Jun 21, 2022
e470027
Update examples and fix missing png
pmpurifoy Jun 21, 2022
422eae8
Add limitations
pmpurifoy Jun 22, 2022
f55aad3
Add ArgumentSerializer and rename APIs
pmpurifoy Jun 24, 2022
aa7ed04
Fix some nits
pmpurifoy Jun 28, 2022
e0b2847
Fix audio ctors
pmpurifoy Jun 28, 2022
15b477c
Add Deserializer functions and example
pmpurifoy Jun 28, 2022
903956a
Apply review changes
pmpurifoy Jun 29, 2022
bbe8a26
Update AppNotificationBuilder-spec.md
pmpurifoy Jun 29, 2022
f5a745f
Initial commit
pmpurifoy Jun 29, 2022
435a152
Working on it
pmpurifoy Jun 30, 2022
238684d
Add AppNotificationContent
pmpurifoy Jun 30, 2022
5423935
Current impl
pmpurifoy Jul 7, 2022
d427450
Working on unit tests
pmpurifoy Jul 13, 2022
5dc491a
Added unit tests
pmpurifoy Jul 14, 2022
2b24c69
Add Audio tests
pmpurifoy Jul 15, 2022
33a4b1b
Update APITests.cpp
pmpurifoy Jul 15, 2022
5bd1f9e
Remove spec from PR
pmpurifoy Jul 15, 2022
41a699e
Rename AppNotification Builder API to match specs (#2766)
loneursid Jul 25, 2022
5ea7ddd
Update the spec with BuildNotification
pmpurifoy Jul 26, 2022
019077a
Remove unused files
pmpurifoy Jul 26, 2022
f45fb7a
Add copyright to all files
pmpurifoy Jul 27, 2022
f81258e
Merge branch 'feature/WNP_ContentBuilder_Prev1' into user/purifoypaul…
loneursid Jul 28, 2022
8851cae
Update AppNotificationBuilder.idl
loneursid Jul 28, 2022
224877f
Update pch.cpp
loneursid Jul 28, 2022
861014d
Update WindowsAppRuntime_DLL.vcxproj
loneursid Jul 28, 2022
a934566
Update packages.config
loneursid Jul 28, 2022
19d0cd4
Update AppNotificationBuilder.cpp
loneursid Jul 28, 2022
9c6bb22
Addressing comments
pmpurifoy Jul 29, 2022
8f51b89
Update error codes with messages
pmpurifoy Jul 29, 2022
f8ed6ca
Add helper file
pmpurifoy Jul 29, 2022
49c02bb
Add SetTimestamp impl
pmpurifoy Jul 29, 2022
3b3b08c
Add AppNotificationAudioLooping
pmpurifoy Jul 29, 2022
604a24f
Add IsSupported to attributes
pmpurifoy Jul 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions WindowsAppRuntime.sln
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeploymentAgent", "dev\Depl
{B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppNotificationBuilder", "dev\AppNotifications\AppNotificationBuilder\AppNotificationBuilder.vcxitems", "{E49329F3-5196-4BBA-B5C4-E11CE7EFB07A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppNotificationBuilderTests", "test\AppNotificationBuilderTests\AppNotificationBuilderTests.vcxproj", "{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.Security.AccessControl.Projection", "dev\Projections\CS\Microsoft.Windows.Security.AccessControl.Projection\Microsoft.Windows.Security.AccessControl.Projection.csproj", "{E6D59245-696F-4D13-ACF6-7ECE6E653367}"
EndProject
Global
Expand Down Expand Up @@ -381,6 +385,7 @@ Global
dev\Deployment\Deployment.vcxitems*{db38fb4d-d04f-4c1d-93e0-f8ae259c5fd6}*SharedItemsImports = 9
dev\EnvironmentManager\ChangeTracker\ChangeTracker.vcxitems*{e15c3465-9d45-495d-92ce-b91ef45e8623}*SharedItemsImports = 9
dev\AppLifecycle\AppLifecycle.vcxitems*{e3a522a3-6635-4a42-bded-1af46a15f63c}*SharedItemsImports = 9
dev\AppNotifications\AppNotificationBuilder\AppNotificationBuilder.vcxitems*{e49329f3-5196-4bba-b5c4-e11ce7efb07a}*SharedItemsImports = 9
test\inc\inc.vcxitems*{e5659a29-fe68-417b-9bc5-613073dd54df}*SharedItemsImports = 4
test\inc\inc.vcxitems*{e977b1bd-00dc-4085-a105-e0a18e0183d7}*SharedItemsImports = 4
EndGlobalSection
Expand Down Expand Up @@ -1357,6 +1362,20 @@ Global
{4410D374-A90C-4ADF-8B15-AA2AAE2636BF}.Release|x64.Build.0 = Release|x64
{4410D374-A90C-4ADF-8B15-AA2AAE2636BF}.Release|x86.ActiveCfg = Release|x86
{4410D374-A90C-4ADF-8B15-AA2AAE2636BF}.Release|x86.Build.0 = Release|x86
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Debug|Any CPU.ActiveCfg = Debug|Win32
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Debug|ARM64.ActiveCfg = Debug|ARM64
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Debug|ARM64.Build.0 = Debug|ARM64
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Debug|x64.ActiveCfg = Debug|x64
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Debug|x64.Build.0 = Debug|x64
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Debug|x86.ActiveCfg = Debug|Win32
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Debug|x86.Build.0 = Debug|Win32
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Release|Any CPU.ActiveCfg = Release|Win32
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Release|ARM64.ActiveCfg = Release|ARM64
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Release|ARM64.Build.0 = Release|ARM64
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Release|x64.ActiveCfg = Release|x64
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Release|x64.Build.0 = Release|x64
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Release|x86.ActiveCfg = Release|Win32
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A}.Release|x86.Build.0 = Release|Win32
{E6D59245-696F-4D13-ACF6-7ECE6E653367}.Debug|Any CPU.ActiveCfg = Debug|x86
{E6D59245-696F-4D13-ACF6-7ECE6E653367}.Debug|ARM64.ActiveCfg = Debug|arm64
{E6D59245-696F-4D13-ACF6-7ECE6E653367}.Debug|ARM64.Build.0 = Debug|arm64
Expand Down Expand Up @@ -1485,6 +1504,8 @@ Global
{D9139E3C-8D21-4BD9-84E3-30A03A54D610} = {99C514E4-A6B3-4B09-B870-5511EF9D93AC}
{4A74BBED-3B20-44A7-B6FF-3373160DE741} = {99C514E4-A6B3-4B09-B870-5511EF9D93AC}
{4410D374-A90C-4ADF-8B15-AA2AAE2636BF} = {E378857C-D22A-4E5E-A6DA-A59C445CF22E}
{E49329F3-5196-4BBA-B5C4-E11CE7EFB07A} = {1C9A0791-2BAA-420B-84B6-C0721F22A6E8}
{131DE0C4-AA1E-4649-B5BC-7B43508FA93A} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
{E6D59245-696F-4D13-ACF6-7ECE6E653367} = {716C26A0-E6B0-4981-8412-D14A4D410531}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
341 changes: 341 additions & 0 deletions dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,341 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#include "pch.h"
#include "AppNotificationBuilder.h"
#include <winrt/Windows.Globalization.h>
#include <winrt/Windows.Globalization.DateTimeFormatting.h>
#include "Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilder.g.cpp"
#include "AppNotificationBuilderUtility.h"
#include <iomanip>
#include <ctime>
#include <sstream>

using namespace winrt::Windows::Globalization;
using namespace winrt::Windows::Globalization::DateTimeFormatting;

namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
Comment thread
pmpurifoy marked this conversation as resolved.
{
bool AppNotificationBuilder::IsUrgentScenarioSupported()
{
return GetBuildNumber() >= 19041;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh. Version checks. That's a minefield (as in, a reliable answer is a minefield...)

Please use functions in dev\common\IsWindowsVersion.h e.g. WindowsVersion::IsWindows10_19H10OrGreater(). That has checks for >=19H1 and >=20H1, and if additional version checks are needed extend as appropos.

That avoids the minefield of GetVersion mechanisms which don't necessarily yield the expected answer

}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::AddArgument(hstring const& key, hstring const& value)
{
THROW_HR_IF_MSG(E_INVALIDARG, key.empty(), "You must provide a key when adding an argument.");

m_arguments.Insert(key, value);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locks? Specifically a write lock

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? AppNotificationBuilder is an instance of an inproc object (like std::wstring). Why would you expect 2 threads to concurrently access the same builder instance? One doesn't expect that for std::string, std::vector and zillions other types.

return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetTimeStamp(winrt::Windows::Foundation::DateTime const& value)
{
auto seconds{ winrt::clock::to_time_t(value) };
struct tm buf;
Comment thread
pmpurifoy marked this conversation as resolved.
gmtime_s(&buf, &seconds);

std::wstringstream buffer;
buffer << std::put_time(&buf, L"%FT%T");

m_timeStamp = wil::str_printf<std::wstring>(L" displayTimestamp='%wsZ'", buffer.str().c_str());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the trailing 'Z'? Should above be std::put_time(..., L"%FT%T%Z") ?

return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetScenario(AppNotificationScenario const& value)
{
m_scenario = value;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lock

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and everywhere else where we access members.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other comment re locks

return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetDuration(AppNotificationDuration const& value)
{
m_duration = value;
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::AddText(hstring const& text)
{
THROW_HR_IF_MSG(E_INVALIDARG, m_textLines.size() >= c_maxTextElements, "Maximum number of text elements added.");

m_textLines.push_back(wil::str_printf<std::wstring>(L"<text>%ws</text>", text.c_str()).c_str());
Comment thread
pmpurifoy marked this conversation as resolved.
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::AddText(hstring const& text, AppNotificationTextProperties const& properties)
{
THROW_HR_IF_MSG(E_INVALIDARG, m_textLines.size() >= c_maxTextElements, "Maximum number of text elements added.");

std::wstring props{ properties.as<winrt::Windows::Foundation::IStringable>().ToString() };
m_textLines.push_back(wil::str_printf<std::wstring>(L"%ws%ws</text>", props.c_str(), text.c_str()).c_str());

if (properties.IncomingCallAlignment())
{
m_scenario = AppNotificationScenario::IncomingCall;
}
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetAttributionText(hstring const& text)
{
m_attributionText = wil::str_printf<std::wstring>(L"<text placement='attribution'>%ws</text>", text.c_str());
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetAttributionText(hstring const& text, hstring const& language)
{
THROW_HR_IF_MSG(E_INVALIDARG, language.empty(), "You must provide a language calling SetAttributionText.");
Comment thread
pmpurifoy marked this conversation as resolved.

m_attributionText = wil::str_printf<std::wstring>(L"<text placement='attribution' lang='%ws'>%ws</text>", language.c_str(), text.c_str());
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetInlineImage(winrt::Windows::Foundation::Uri const& imageUri)
{
m_inlineImage = wil::str_printf<std::wstring>(L"<image src='%ws'/>", imageUri.ToString().c_str());
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetInlineImage(winrt::Windows::Foundation::Uri const& imageUri, AppNotificationImageCrop const& imageCrop)
{
if (imageCrop == AppNotificationImageCrop::Circle)
{
m_inlineImage = wil::str_printf<std::wstring>(L"<image src='%ws' hint-crop='circle'/>", imageUri.ToString().c_str());
}
else
{
SetInlineImage(imageUri);
}

return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetInlineImage(winrt::Windows::Foundation::Uri const& imageUri, AppNotificationImageCrop const& imageCrop, hstring const& alternateText)
{
THROW_HR_IF_MSG(E_INVALIDARG, alternateText.empty(), "You must provide an alternate text string calling SetInlineImage.");

std::wstring hintCrop { imageCrop == AppNotificationImageCrop::Circle ? L" hint-crop='circle'" : L"" };
m_inlineImage = wil::str_printf<std::wstring>(L"<image src='%ws' alt='%ws'%ws/>", imageUri.ToString().c_str(), alternateText.c_str(), hintCrop.c_str());

return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetAppLogoOverride(winrt::Windows::Foundation::Uri const& imageUri)
{
m_appLogoOverride = wil::str_printf<std::wstring>(L"<image placement='appLogoOverride' src='%ws'/>", imageUri.ToString().c_str());
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetAppLogoOverride(winrt::Windows::Foundation::Uri const& imageUri, AppNotificationImageCrop const& imageCrop)
{
if (imageCrop == AppNotificationImageCrop::Circle)
{
m_appLogoOverride = wil::str_printf<std::wstring>(L"<image placement='appLogoOverride' src='%ws' hint-crop='circle'/>", imageUri.ToString().c_str());
}
else
{
SetAppLogoOverride(imageUri);
}

return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetAppLogoOverride(winrt::Windows::Foundation::Uri const& imageUri, AppNotificationImageCrop const& imageCrop, hstring const& alternateText)
{
THROW_HR_IF_MSG(E_INVALIDARG, alternateText.empty(), "You must provide an alternate text string calling SetAppLogoOverride.");

std::wstring hintCrop{ imageCrop == AppNotificationImageCrop::Circle ? L" hint-crop='circle'" : L"" };
m_appLogoOverride = wil::str_printf<std::wstring>(L"<image placement='appLogoOverride' src='%ws' alt='%ws'%ws/>", imageUri.ToString().c_str(), alternateText.c_str(), hintCrop.c_str());

return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetHeroImage(winrt::Windows::Foundation::Uri const& imageUri)
{
m_heroImage = wil::str_printf<std::wstring>(L"<image placement='hero' src='%ws'/>", imageUri.ToString().c_str());
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetHeroImage(winrt::Windows::Foundation::Uri const& imageUri, hstring const& alternateText)
{
THROW_HR_IF_MSG(E_INVALIDARG, alternateText.empty(), "You must provide an alternate text string calling SetHeroImage.");

m_heroImage = wil::str_printf<std::wstring>(L"<image placement='hero' src='%ws' alt='%ws'/>", imageUri.ToString().c_str(), alternateText.c_str());
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetAudioUri(winrt::Windows::Foundation::Uri const& audioUri)
{
m_audio = wil::str_printf<std::wstring>(L"<audio src='%ws'/>", audioUri.ToString().c_str());
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetAudioUri(winrt::Windows::Foundation::Uri const& audioUri, AppNotificationAudioLooping const& loop)
{
m_audio = wil::str_printf<std::wstring>(L"<audio src='%ws' loop='%ws'/>", audioUri.ToString().c_str(), loop == AppNotificationAudioLooping::Loop ? L"true" : L"false");
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetAudioEvent(AppNotificationSoundEvent const& soundEvent)
{
m_audio = wil::str_printf<std::wstring>(L"<audio src='%ws'/>", GetWinSoundEventString(soundEvent).c_str());
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetAudioEvent(AppNotificationSoundEvent const& soundEvent, AppNotificationAudioLooping const& loop)
{
m_audio = wil::str_printf<std::wstring>(L"<audio src='%ws' loop='%ws'/>", GetWinSoundEventString(soundEvent).c_str(), loop == AppNotificationAudioLooping::Loop ? L"true" : L"false");
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::MuteAudio()
{
m_audio = L"<audio silent='true'/>";
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::AddButton(AppNotificationButton const& value)
{
THROW_HR_IF_MSG(E_INVALIDARG, m_buttonList.size() >= c_maxButtonElements, "Maximum number of buttons added.");

m_buttonList.push_back(value);
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetTag(hstring const& value)
{
m_tag = value;
return *this;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::SetGroup(hstring const& value)
{
m_group = value;
return *this;
}

std::wstring AppNotificationBuilder::GetDuration()
{
return m_duration == AppNotificationDuration::Default ? L"" : L" duration='long'";
}

std::wstring AppNotificationBuilder::GetScenario()
{
// Add scenario attribute if set
switch (m_scenario)
{
case AppNotificationScenario::Alarm:
return L" scenario='alarm'";
case AppNotificationScenario::Reminder:
return L" scenario='reminder'";
case AppNotificationScenario::IncomingCall:
return L" scenario='incomingCall'";
case AppNotificationScenario::Urgent:
return L" scenario='urgent'";
default:
return {};
}
}

std::wstring AppNotificationBuilder::GetArguments()
{
// Add launch arguments if given arguments
if (m_arguments.Size())
{
std::wstring arguments{ };
Comment thread
pmpurifoy marked this conversation as resolved.
for (auto pair : m_arguments)
{
if (!pair.Value().empty())
{
arguments.append(wil::str_printf<std::wstring>(L"%ws=%ws;", pair.Key().c_str(), pair.Value().c_str()));
}
else
{
arguments.append(wil::str_printf<std::wstring>(L"%ws;", pair.Key().c_str()));
}
}
arguments.pop_back();

return wil::str_printf<std::wstring>(L" launch='%ws'", arguments.c_str());
}
else
{
return {};
}
}

std::wstring AppNotificationBuilder::GetText()
{
std::wstring result{};
for (auto text : m_textLines)
{
result.append(text);
}

return result;
}

std::wstring AppNotificationBuilder::GetImages()
{
return wil::str_printf<std::wstring>(L"%ws%ws%ws", m_inlineImage.c_str(), m_heroImage.c_str(), m_appLogoOverride.c_str());
}

std::wstring AppNotificationBuilder::GetButtons()
{
if (m_buttonList.size())
{
std::wstring result{};
for (auto input : m_buttonList)
{
if (input.ButtonStyle() != AppNotificationButtonStyle::Default)
{
m_useButtonStyle = true;
}

result.append(input.as<winrt::Windows::Foundation::IStringable>().ToString().c_str());
}

return wil::str_printf<std::wstring>(L"<actions>%ws</actions>", result.c_str());
}
else
{
return {};
}
}

// You must call GetButtons first to retrieve this value.
std::wstring AppNotificationBuilder::GetButtonStyle()
{
return m_useButtonStyle ? L" useButtonStyle='true'" : L"";
}

winrt::Microsoft::Windows::AppNotifications::AppNotification AppNotificationBuilder::BuildNotification()
{
std::wstring xmlResult{};
xmlResult.reserve(c_maxAppNotificationPayload);

// Build the button string and fill m_useButtonStyle
std::wstring buttons{ GetButtons() };

xmlResult.append(L"<toast");
xmlResult.append(m_timeStamp);
xmlResult.append(GetDuration());
xmlResult.append(GetScenario());
xmlResult.append(GetArguments());
xmlResult.append(GetButtonStyle());
xmlResult.append(L"><visual><binding template='ToastGeneric'>");
xmlResult.append(GetText());
xmlResult.append(m_attributionText);
xmlResult.append(GetImages());
xmlResult.append(L"</binding></visual>");
xmlResult.append(m_audio.c_str());
xmlResult.append(buttons);
xmlResult.append(L"</toast>");

winrt::Microsoft::Windows::AppNotifications::AppNotification appNotification{ xmlResult };
appNotification.Tag(m_tag);
appNotification.Group(m_group);

return appNotification;
}
}
Loading