diff --git a/WindowsAppRuntime.sln b/WindowsAppRuntime.sln index 266ae49a34..d9c55d3f34 100644 --- a/WindowsAppRuntime.sln +++ b/WindowsAppRuntime.sln @@ -566,6 +566,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IXP", "IXP", "{7B323048-439 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IXP.TransportPackage.PackageReference", "eng\PackageReference\IXP\IXP.TransportPackage.PackageReference.csproj", "{A949149D-29CA-4AA7-B1ED-0E571B4AD9BB}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Notifications", "Notifications", "{43FE6980-3E16-4EF9-A3DE-29B402FB4FAB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BaseNotifications", "BaseNotifications", "{586EA218-74C8-420B-B47E-0B307AA4B82D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BadgeNotifications", "BadgeNotifications", "{50205ED9-0E08-4878-B124-9AC0EBA138D6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BadgeNotifications", "dev\Notifications\BadgeNotifications\BadgeNotifications.vcxitems", "{85D111C7-B720-4E19-A56D-03C87B953983}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaseNotifications", "dev\Notifications\BaseNotifications\BaseNotifications.vcxitems", "{2BD7A1BB-D3D8-484F-9180-409D781DCCF9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Windows.BadgeNotifications.Projection", "dev\Projections\CS\Microsoft.Windows.BadgeNotifications.Projection\Microsoft.Windows.BadgeNotifications.Projection.csproj", "{A243A58D-ABD7-4520-8C71-F492247B7B92}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -2002,6 +2014,22 @@ Global {A949149D-29CA-4AA7-B1ED-0E571B4AD9BB}.Release|x64.Build.0 = Release|x64 {A949149D-29CA-4AA7-B1ED-0E571B4AD9BB}.Release|x86.ActiveCfg = Release|x86 {A949149D-29CA-4AA7-B1ED-0E571B4AD9BB}.Release|x86.Build.0 = Release|x86 + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Debug|ARM64.Build.0 = Debug|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Debug|x64.ActiveCfg = Debug|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Debug|x64.Build.0 = Debug|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Debug|x86.ActiveCfg = Debug|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Debug|x86.Build.0 = Debug|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Release|Any CPU.Build.0 = Release|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Release|ARM64.ActiveCfg = Release|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Release|ARM64.Build.0 = Release|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Release|x64.ActiveCfg = Release|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Release|x64.Build.0 = Release|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Release|x86.ActiveCfg = Release|Any CPU + {A243A58D-ABD7-4520-8C71-F492247B7B92}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2181,6 +2209,12 @@ Global {D5958784-4518-44F1-A518-80514B380ED5} = {E24C263A-DE3E-4844-BA50-842DA5AD7A49} {7B323048-439F-47E9-A3D4-7342C5ADE2A5} = {5C88AE1D-AC20-4A41-9299-1EEA15B80724} {A949149D-29CA-4AA7-B1ED-0E571B4AD9BB} = {7B323048-439F-47E9-A3D4-7342C5ADE2A5} + {43FE6980-3E16-4EF9-A3DE-29B402FB4FAB} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A} + {586EA218-74C8-420B-B47E-0B307AA4B82D} = {43FE6980-3E16-4EF9-A3DE-29B402FB4FAB} + {50205ED9-0E08-4878-B124-9AC0EBA138D6} = {43FE6980-3E16-4EF9-A3DE-29B402FB4FAB} + {85D111C7-B720-4E19-A56D-03C87B953983} = {50205ED9-0E08-4878-B124-9AC0EBA138D6} + {2BD7A1BB-D3D8-484F-9180-409D781DCCF9} = {586EA218-74C8-420B-B47E-0B307AA4B82D} + {A243A58D-ABD7-4520-8C71-F492247B7B92} = {716C26A0-E6B0-4981-8412-D14A4D410531} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4B3D7591-CFEC-4762-9A07-ABE99938FB77} @@ -2188,6 +2222,7 @@ Global GlobalSection(SharedMSBuildProjectFiles) = preSolution test\inc\inc.vcxitems*{08bc78e0-63c6-49a7-81b3-6afc3deac4de}*SharedItemsImports = 4 dev\PushNotifications\PushNotifications.vcxitems*{103c0c23-7ba8-4d44-a63c-83488e2e3a81}*SharedItemsImports = 9 + dev\Notifications\BaseNotifications\BaseNotifications.vcxitems*{2bd7a1bb-d3d8-484f-9180-409d781dccf9}*SharedItemsImports = 9 dev\EnvironmentManager\API\Microsoft.Process.Environment.vcxitems*{2f3fad1b-d3df-4866-a3a3-c2c777d55638}*SharedItemsImports = 9 dev\OAuth\OAuth.vcxitems*{3e7fd510-8b66-40e7-a80b-780cb8972f83}*SharedItemsImports = 9 test\inc\inc.vcxitems*{412d023e-8635-4ad2-a0ea-e19e08d36915}*SharedItemsImports = 4 @@ -2198,6 +2233,7 @@ Global test\inc\inc.vcxitems*{7c502995-59c3-483b-86ba-815985353633}*SharedItemsImports = 4 dev\ApplicationData\ApplicationData.vcxitems*{7cf52890-56fa-47e2-84fb-68ee274324b6}*SharedItemsImports = 9 dev\BackgroundTask\BackgroundTaskBuilder\BackgroundTaskBuilder.vcxitems*{858fa9a9-f822-4b98-84a1-fe44e2c00a5d}*SharedItemsImports = 9 + dev\Notifications\BadgeNotifications\BadgeNotifications.vcxitems*{85d111c7-b720-4e19-a56d-03c87b953983}*SharedItemsImports = 9 dev\Common\Common.vcxitems*{8828053c-d6ec-4744-8624-f8c676c2d4df}*SharedItemsImports = 9 dev\Licensing\Licensing.vcxitems*{885a43fa-052d-4b0d-a2dc-13ee15796435}*SharedItemsImports = 9 dev\PackageManager\API\PackageManager.vcxitems*{8a9a0c85-65a8-4bca-a49e-45fc4fdbc7d2}*SharedItemsImports = 9 diff --git a/build/CopyFilesToStagingDir.ps1 b/build/CopyFilesToStagingDir.ps1 index 3c261aaac2..f73036ee7c 100644 --- a/build/CopyFilesToStagingDir.ps1 +++ b/build/CopyFilesToStagingDir.ps1 @@ -53,6 +53,7 @@ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windo PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.AppLifecycle.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.AppNotifications.Builder.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.AppNotifications.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\ +PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.BadgeNotifications.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.Management.Deployment.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.Media.Capture.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.PushNotifications.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\ @@ -200,6 +201,7 @@ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windo PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.AppLifecycle.winmd $NugetDir\lib\uap10.0 PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.AppNotifications.Builder.winmd $NugetDir\lib\uap10.0 PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.AppNotifications.winmd $NugetDir\lib\uap10.0 +PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.BadgeNotifications.winmd $NugetDir\lib\uap10.0 PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.Management.Deployment.winmd $NugetDir\lib\uap10.0 PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.Media.Capture.winmd $NugetDir\lib\uap10.0 PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.PushNotifications.winmd $NugetDir\lib\uap10.0 diff --git a/build/NuSpecs/AppxManifest.xml b/build/NuSpecs/AppxManifest.xml index e079468216..6dac600300 100644 --- a/build/NuSpecs/AppxManifest.xml +++ b/build/NuSpecs/AppxManifest.xml @@ -1,4 +1,4 @@ - + @@ -111,6 +111,9 @@ + + + diff --git a/build/NuSpecs/WindowsAppSDK-Nuget-Native.WinRt.props b/build/NuSpecs/WindowsAppSDK-Nuget-Native.WinRt.props index 88fede76fd..45fe60f31a 100644 --- a/build/NuSpecs/WindowsAppSDK-Nuget-Native.WinRt.props +++ b/build/NuSpecs/WindowsAppSDK-Nuget-Native.WinRt.props @@ -75,6 +75,12 @@ $(MSBuildThisFileDirectory)..\..\runtimes\win10-$(_WindowsAppSDKFoundationPlatform)\native\Microsoft.WindowsAppRuntime.dll true + + $(MSBuildThisFileDirectory)..\..\lib\uap10.0\Microsoft.Windows.BadgeNotifications.winmd + $(MSBuildThisFileDirectory)..\..\runtimes\win10-$(_WindowsAppSDKFoundationPlatform)\native\Microsoft.WindowsAppRuntime.dll + true + diff --git a/build/NuSpecs/WindowsAppSDK-Nuget-Native.targets b/build/NuSpecs/WindowsAppSDK-Nuget-Native.targets index c18bdb650a..506c223359 100644 --- a/build/NuSpecs/WindowsAppSDK-Nuget-Native.targets +++ b/build/NuSpecs/WindowsAppSDK-Nuget-Native.targets @@ -135,6 +135,14 @@ + + + false + Microsoft.WindowsAppRuntime.dll + + + diff --git a/dev/AppNotifications/NotificationProperties.cpp b/dev/AppNotifications/NotificationProperties.cpp index c06167106c..2dfe21f253 100644 --- a/dev/AppNotifications/NotificationProperties.cpp +++ b/dev/AppNotifications/NotificationProperties.cpp @@ -29,7 +29,7 @@ namespace Helpers NotificationProperties::NotificationProperties(winrt::AppNotification const& toastNotification) { // Extract payload and convert it from XML to a byte array - auto payloadAsSimpleString = Helpers::WideStringToUtf8String(toastNotification.Payload()); + auto payloadAsSimpleString = Helpers::WideStringToPayloadUtf8String(toastNotification.Payload()); m_payload = wil::unique_cotaskmem_array_ptr(static_cast(CoTaskMemAlloc(payloadAsSimpleString.size())), payloadAsSimpleString.size()); THROW_IF_NULL_ALLOC(m_payload.get()); @@ -57,6 +57,31 @@ NotificationProperties::NotificationProperties(winrt::AppNotification const& toa m_toastConferencingConfig = winrt::make_self(config); } } + + + m_notificationType = ToastABI::NotificationType::NotificationType_Toast; +} + +NotificationProperties::NotificationProperties(Microsoft::Windows::BadgeNotifications::BadgeNotification &badgeNotification) +{ + // Extract payload and convert it from XML to a byte array + auto payloadAsSimpleString = Helpers::WideStringToPayloadUtf8String(badgeNotification.Payload()); + + m_payload = wil::unique_cotaskmem_array_ptr(static_cast(CoTaskMemAlloc(payloadAsSimpleString.size())), payloadAsSimpleString.size()); + THROW_IF_NULL_ALLOC(m_payload.get()); + CopyMemory(m_payload.data(), payloadAsSimpleString.c_str(), payloadAsSimpleString.size()); + + m_notificationId = badgeNotification.Id(); + + m_tag = badgeNotification.Tag(); + m_group = badgeNotification.Group(); + + m_expiry = winrt::clock::to_file_time(badgeNotification.Expiration()); + m_arrivalTime = winrt::clock::to_file_time(winrt::clock::now()); + + m_expiresOnReboot = badgeNotification.ExpiresOnReboot(); + + m_notificationType = badgeNotification.NotificationType(); } STDMETHODIMP_(HRESULT __stdcall) NotificationProperties::get_NotificationId(_Out_ unsigned int* notificationId) noexcept @@ -164,3 +189,11 @@ STDMETHODIMP_(HRESULT __stdcall) NotificationProperties::get_ToastConferencingCo m_toastConferencingConfig.copy_to(conferencingConfig); return S_OK; } + +STDMETHODIMP_(HRESULT __stdcall) NotificationProperties::get_NotificationType(_Out_ ToastABI::NotificationType* notificationType) noexcept +{ + auto lock{ m_lock.lock_shared() }; + *notificationType = m_notificationType; + + return S_OK; +} diff --git a/dev/AppNotifications/NotificationProperties.h b/dev/AppNotifications/NotificationProperties.h index ec6aaffae9..d975cc0e97 100644 --- a/dev/AppNotifications/NotificationProperties.h +++ b/dev/AppNotifications/NotificationProperties.h @@ -4,11 +4,15 @@ #pragma once #include +#include "BadgeNotification.h" -struct NotificationProperties : winrt::implements +struct NotificationProperties : winrt::implements { NotificationProperties(winrt::Microsoft::Windows::AppNotifications::AppNotification const& toastNotification); + NotificationProperties(Microsoft::Windows::BadgeNotifications::BadgeNotification &badgeNotification); + STDMETHOD(get_NotificationId)(_Out_ unsigned int* notificationId) noexcept; STDMETHOD(get_Payload)(_Out_ unsigned int* payloadSize, _Out_ byte** payload) noexcept; @@ -33,6 +37,8 @@ struct NotificationProperties : winrt::implements m_toastProgressData{ nullptr }; winrt::com_ptr m_toastConferencingConfig{ nullptr }; + + ABI::Microsoft::Internal::ToastNotifications::NotificationType m_notificationType; }; diff --git a/dev/AppNotifications/NotificationTransientProperties.cpp b/dev/AppNotifications/NotificationTransientProperties.cpp index 80c22e7350..9aad26886b 100644 --- a/dev/AppNotifications/NotificationTransientProperties.cpp +++ b/dev/AppNotifications/NotificationTransientProperties.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #include "pch.h" @@ -28,6 +28,16 @@ NotificationTransientProperties::NotificationTransientProperties(winrt::AppNotif } } +NotificationTransientProperties::NotificationTransientProperties(_In_ Microsoft::Windows::BadgeNotifications::BadgeNotification &badgeNotification) noexcept +{ + m_suppressPopup = badgeNotification.SuppressDisplay(); + + if (badgeNotification.Priority() == winrt::AppNotificationPriority::High) + { + m_toastNotificationPriority = ToastABI::ToastNotificationPriority::ToastNotificationPriority_High; + } +} + STDMETHODIMP_(HRESULT __stdcall) NotificationTransientProperties::get_OfflineCacheCount(_Out_ unsigned long long* offlineCacheCount) noexcept { *offlineCacheCount = 0; diff --git a/dev/AppNotifications/NotificationTransientProperties.h b/dev/AppNotifications/NotificationTransientProperties.h index 0c45c8e972..58b894c612 100644 --- a/dev/AppNotifications/NotificationTransientProperties.h +++ b/dev/AppNotifications/NotificationTransientProperties.h @@ -1,14 +1,17 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #pragma once #include +#include "BadgeNotification.h" struct NotificationTransientProperties : winrt::implements { NotificationTransientProperties(winrt::Microsoft::Windows::AppNotifications::AppNotification const& toastNotification) noexcept; + NotificationTransientProperties(Microsoft::Windows::BadgeNotifications::BadgeNotification &badgeNotification) noexcept; + STDMETHOD(get_OfflineCacheCount)(_Out_ unsigned long long* offlineCacheCount) noexcept; STDMETHOD(get_OfflineBundleId)(_Out_ HSTRING* offlineBundleId) noexcept; diff --git a/dev/Common/TerminalVelocityFeatures-BadgeNotifications.h b/dev/Common/TerminalVelocityFeatures-BadgeNotifications.h new file mode 100644 index 0000000000..de96769c44 --- /dev/null +++ b/dev/Common/TerminalVelocityFeatures-BadgeNotifications.h @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT IT + +// INPUT FILE: dev\common\TerminalVelocityFeatures-BadgeNotifications.xml +// OPTIONS: -Channel Experimental -Language C++ -Namespace Microsoft.Windows.BadgeNotifications -Path dev\common\TerminalVelocityFeatures-BadgeNotifications.xml -Output dev\common\TerminalVelocityFeatures-BadgeNotifications.h + +#if defined(__midlrt) +namespace features +{ + feature_name Feature_BadgeNotifications = { DisabledByDefault, FALSE }; +} +#endif // defined(__midlrt) + +// Feature constants +#define WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_BADGENOTIFICATIONS_FEATURE_BADGENOTIFICATIONS_ENABLED 1 + +#if defined(__cplusplus) + +namespace Microsoft::Windows::BadgeNotifications +{ + + __pragma(detect_mismatch("ODR_violation_WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_BADGENOTIFICATIONS_FEATURE_BADGENOTIFICATIONS_ENABLED_mismatch", "AlwaysEnabled")) + struct Feature_BadgeNotifications + { + static constexpr bool IsEnabled() { return WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_BADGENOTIFICATIONS_FEATURE_BADGENOTIFICATIONS_ENABLED == 1; } + }; + +} // namespace Microsoft.Windows.BadgeNotifications + +#endif // defined(__cplusplus) diff --git a/dev/Common/TerminalVelocityFeatures-BadgeNotifications.xml b/dev/Common/TerminalVelocityFeatures-BadgeNotifications.xml new file mode 100644 index 0000000000..d88bceb864 --- /dev/null +++ b/dev/Common/TerminalVelocityFeatures-BadgeNotifications.xml @@ -0,0 +1,23 @@ + + + + + + + + + + Feature_BadgeNotifications + Enables Local Badge sourced Notifications for packaged apps on the device + AlwaysEnabled + + Preview + Stable + + + + diff --git a/dev/Notifications/BadgeNotifications/BadgeNotification.cpp b/dev/Notifications/BadgeNotifications/BadgeNotification.cpp new file mode 100644 index 0000000000..32fc89c6fb --- /dev/null +++ b/dev/Notifications/BadgeNotifications/BadgeNotification.cpp @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include "pch.h" +#include "BadgeNotification.h" +#include + +using namespace Microsoft::Windows::BaseNotifications; + +namespace ToastABI +{ + using namespace ::ABI::Microsoft::Internal::ToastNotifications; +} + +namespace Microsoft::Windows::BadgeNotifications { + // Default constructor + BadgeNotification::BadgeNotification() : BaseNotification() + { + BaseNotification::NotificationType(ToastABI::NotificationType::NotificationType_Badge); + } + + // Constructor that takes a payload and forwards it to the base class constructor + BadgeNotification::BadgeNotification(winrt::hstring const& payload) : BaseNotification(payload) + { + BaseNotification::NotificationType(ToastABI::NotificationType::NotificationType_Badge); + } +} diff --git a/dev/Notifications/BadgeNotifications/BadgeNotification.h b/dev/Notifications/BadgeNotifications/BadgeNotification.h new file mode 100644 index 0000000000..6a1a1cdbdd --- /dev/null +++ b/dev/Notifications/BadgeNotifications/BadgeNotification.h @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include +#include "BaseNotification.h" + + +namespace Microsoft::Windows::BadgeNotifications +{ + struct BadgeNotification : Microsoft::Windows::BaseNotifications::BaseNotification + { + BadgeNotification(); + BadgeNotification(winrt::hstring const& payload); + }; +} diff --git a/dev/Notifications/BadgeNotifications/BadgeNotificationManager.cpp b/dev/Notifications/BadgeNotifications/BadgeNotificationManager.cpp new file mode 100644 index 0000000000..bf9c4b4734 --- /dev/null +++ b/dev/Notifications/BadgeNotifications/BadgeNotificationManager.cpp @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include "pch.h" +#include "BadgeNotificationManager.h" +#include "Microsoft.Windows.BadgeNotifications.BadgeNotificationManager.g.cpp" +#include "externs.h" +#include "AppNotificationUtility.h" +#include "NotificationProperties.h" +#include "NotificationTransientProperties.h" +#include +#include +#include +#include +#include "BadgeNotification.h" +#include "BadgeNotificationTelemetry.h" + +using namespace std::literals; + +namespace winrt +{ + using namespace winrt::Windows::UI; + using namespace winrt::Windows::Foundation; + using namespace winrt::Windows::Foundation::Collections; + using namespace winrt::Microsoft::Windows::AppNotifications; + using namespace Windows::ApplicationModel::Core; + using namespace winrt::Microsoft::Windows::BadgeNotifications; +} + +namespace ToastABI +{ + using namespace ::ABI::Microsoft::Internal::ToastNotifications; + using namespace ::ABI::Windows::Foundation::Collections; +} + +using namespace Microsoft::Windows::AppNotifications::Helpers; +using namespace Microsoft::Windows::AppNotifications::ShellLocalization; + + +namespace winrt::Microsoft::Windows::BadgeNotifications::implementation +{ + BadgeNotificationManager::BadgeNotificationManager() : m_processName(GetCurrentProcessPath()), m_appId(RetrieveNotificationAppId()) {} + + winrt::Microsoft::Windows::BadgeNotifications::BadgeNotificationManager BadgeNotificationManager::Current() + { + auto appProperties{ winrt::CoreApplication::Properties() }; + + static wil::srwlock lock; + + auto criticalSection{ lock.lock_exclusive() }; + auto storedBadgeNotificationManager{ appProperties.TryLookup(STORED_BADGENOTIFICATION_MANAGER_KEY) }; + if (storedBadgeNotificationManager) + { + return storedBadgeNotificationManager.as(); + } + else + { + // Need to clear the RoActivateInstance caching for the PushNotificationLongRunningProcess proxyStub to be found. + ::Microsoft::RoApi::ClearRoActivateInstanceCache(); + + // Store the BadgeNotificationManager in the COM static store + auto badgeNotificationManager{ winrt::make() }; + appProperties.Insert(STORED_BADGENOTIFICATION_MANAGER_KEY, badgeNotificationManager); + return badgeNotificationManager; + } + } + + void BadgeNotificationManager::SetBadgeAsCount(uint32_t notificationCount) + { + THROW_HR_IF_MSG(E_ILLEGAL_METHOD_CALL, !AppModel::Identity::IsPackagedProcess(), "Not applicable for unpackaged applications"); + + auto logTelemetry{ BadgeNotificationTelemetry::SetBadgeAsCount::Start( + g_telemetryHelper, + m_appId) }; + + SetBadge(std::to_wstring(notificationCount), nullptr); + + logTelemetry.Stop(); + + return; + } + + void BadgeNotificationManager::SetBadgeAsCount(uint32_t notificationCount, winrt::DateTime expiration) + { + THROW_HR_IF_MSG(E_ILLEGAL_METHOD_CALL, !AppModel::Identity::IsPackagedProcess(), "Not applicable for unpackaged applications"); + + auto logTelemetry{ BadgeNotificationTelemetry::SetBadgeAsCountWithExpiration::Start( + g_telemetryHelper, + m_appId) }; + + SetBadge(std::to_wstring(notificationCount), &expiration); + + logTelemetry.Stop(); + + return; + } + + void BadgeNotificationManager::SetBadgeAsGlyph(winrt::BadgeNotificationGlyph glyphValue) + { + THROW_HR_IF_MSG(E_ILLEGAL_METHOD_CALL, !AppModel::Identity::IsPackagedProcess(), "Not applicable for unpackaged applications"); + + auto logTelemetry{ BadgeNotificationTelemetry::SetBadgeAsGlyph::Start( + g_telemetryHelper, + m_appId) }; + + std::wstring glyphValueString = GetBadgeNotificationGlyphToString(glyphValue); + + THROW_HR_IF_MSG(E_INVALIDARG, glyphValueString.empty(), "Invalid Glyph value"); + + SetBadge(glyphValueString, nullptr); + + logTelemetry.Stop(); + + return; + } + + void BadgeNotificationManager::SetBadgeAsGlyph(winrt::BadgeNotificationGlyph glyphValue, winrt::DateTime expiration) + { + THROW_HR_IF_MSG(E_ILLEGAL_METHOD_CALL, !AppModel::Identity::IsPackagedProcess(), "Not applicable for unpackaged applications"); + + auto logTelemetry{ BadgeNotificationTelemetry::SetBadgeAsGlyphWithExpiration::Start( + g_telemetryHelper, + m_appId) }; + + std::wstring glyphValueString = GetBadgeNotificationGlyphToString(glyphValue); + + THROW_HR_IF_MSG(E_INVALIDARG, glyphValueString.empty(), "Invalid Glyph value"); + + SetBadge(glyphValueString, &expiration); + + logTelemetry.Stop(); + + return; + } + + void BadgeNotificationManager::ClearBadge() + { + THROW_HR_IF_MSG(E_ILLEGAL_METHOD_CALL, !AppModel::Identity::IsPackagedProcess(), "Not applicable for unpackaged applications"); + + auto logTelemetry{ BadgeNotificationTelemetry::ClearBadge::Start( + g_telemetryHelper, + m_appId) }; + + THROW_IF_FAILED(WnpNotifications_RemoveAllNotificationsForAppOfType(m_appId.c_str(), ToastABI::NotificationType::NotificationType_Badge)); + + logTelemetry.Stop(); + + return; + } + + std::wstring BadgeNotificationManager::GetBadgeNotificationGlyphToString(_In_ winrt::BadgeNotificationGlyph glyphValue) + { + constexpr static std::pair enumMapping[] = { + {winrt::BadgeNotificationGlyph::None, L"none"}, + {winrt::BadgeNotificationGlyph::Activity, L"activity"}, + {winrt::BadgeNotificationGlyph::Alarm, L"alarm"}, + {winrt::BadgeNotificationGlyph::Alert, L"alert"}, + {winrt::BadgeNotificationGlyph::Attention, L"attention"}, + {winrt::BadgeNotificationGlyph::Available, L"available"}, + {winrt::BadgeNotificationGlyph::Away, L"away"}, + {winrt::BadgeNotificationGlyph::Busy, L"busy"}, + {winrt::BadgeNotificationGlyph::Error, L"error"}, + {winrt::BadgeNotificationGlyph::NewMessage, L"newMessage"}, + {winrt::BadgeNotificationGlyph::Paused, L"paused"}, + {winrt::BadgeNotificationGlyph::Playing, L"playing"}, + {winrt::BadgeNotificationGlyph::Unavailable, L"unavailable"} + }; + + auto it = std::find_if(std::begin(enumMapping), std::end(enumMapping), [&](const auto& item) + { + return item.first == glyphValue; + }); + + if (it != std::end(enumMapping)) + { + return std::wstring(it->second); // Return the string directly + } + else + { + return std::wstring(); // Return an empty string if not found + } + } + + void BadgeNotificationManager::SetBadge(_In_ const std::wstring& value, _In_opt_ const winrt::Windows::Foundation::DateTime* expiration) + { + auto xmlResult = wil::str_printf(L"", value.c_str()); + ::Microsoft::Windows::BadgeNotifications::BadgeNotification badgeNotification(xmlResult.c_str()); + + if (expiration != nullptr) + { + badgeNotification.Expiration(*expiration); + } + + THROW_HR_IF(WPN_E_NOTIFICATION_POSTED, badgeNotification.Id() != 0); + + winrt::com_ptr<::ABI::Microsoft::Internal::ToastNotifications::INotificationProperties> notificationProperties = winrt::make_self(badgeNotification); + + winrt::com_ptr<::ABI::Microsoft::Internal::ToastNotifications::INotificationTransientProperties> notificationTransientProperties = winrt::make_self(badgeNotification); + + DWORD notificationId = 0; + THROW_IF_FAILED(ToastNotifications_PostToast(m_appId.c_str(), notificationProperties.get(), notificationTransientProperties.get(), ¬ificationId)); + + THROW_HR_IF(E_UNEXPECTED, notificationId == 0); + + badgeNotification.Id(notificationId); + return; + } +} diff --git a/dev/Notifications/BadgeNotifications/BadgeNotificationManager.h b/dev/Notifications/BadgeNotifications/BadgeNotificationManager.h new file mode 100644 index 0000000000..75c3542112 --- /dev/null +++ b/dev/Notifications/BadgeNotifications/BadgeNotificationManager.h @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation and Contributors. All rights reserved. +// Licensed under the MIT License. + +#pragma once +#include "Microsoft.Windows.BadgeNotifications.BadgeNotificationManager.g.h" +#include "externs.h" + +namespace winrt::Microsoft::Windows::BadgeNotifications::implementation +{ + struct BadgeNotificationManager : BadgeNotificationManagerT + { + BadgeNotificationManager(); + + static winrt::Microsoft::Windows::BadgeNotifications::BadgeNotificationManager Current(); + + void SetBadgeAsCount(_In_ uint32_t notificationCount); + void SetBadgeAsCount(_In_ uint32_t notificationCount, _In_ winrt::Windows::Foundation::DateTime expiration); + + void SetBadgeAsGlyph(_In_ winrt::Microsoft::Windows::BadgeNotifications::BadgeNotificationGlyph glyphValue); + void SetBadgeAsGlyph(_In_ winrt::Microsoft::Windows::BadgeNotifications::BadgeNotificationGlyph glyphValue, _In_ winrt::Windows::Foundation::DateTime expiration); + + void ClearBadge(); + + private: + std::wstring GetBadgeNotificationGlyphToString(_In_ winrt::Microsoft::Windows::BadgeNotifications::BadgeNotificationGlyph glyphValue); + void SetBadge(_In_ const std::wstring& value, _In_opt_ const winrt::Windows::Foundation::DateTime* expiration); + std::wstring m_processName; + std::wstring m_appId; + }; + + struct BadgeNotificationManagerFactory : winrt::implements + { + STDMETHODIMP CreateInstance(_In_opt_ IUnknown* aggregateInterface, _In_ REFIID interfaceId, _Outptr_ VOID** object) noexcept final try + { + RETURN_HR_IF(CLASS_E_NOAGGREGATION, aggregateInterface != nullptr); + return BadgeNotificationManager::Current().as(interfaceId, object); + } + CATCH_RETURN() + + STDMETHODIMP LockServer(BOOL fLock) noexcept final + { + if (fLock) + { + ++winrt::get_module_lock(); + } + else + { + --winrt::get_module_lock(); + } + return S_OK; + } + }; +} +namespace winrt::Microsoft::Windows::BadgeNotifications::factory_implementation +{ + struct BadgeNotificationManager : BadgeNotificationManagerT + { + }; +} diff --git a/dev/Notifications/BadgeNotifications/BadgeNotificationTelemetry.h b/dev/Notifications/BadgeNotifications/BadgeNotificationTelemetry.h new file mode 100644 index 0000000000..2abe43ad7a --- /dev/null +++ b/dev/Notifications/BadgeNotifications/BadgeNotificationTelemetry.h @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once + +#include +#include + +DECLARE_TRACELOGGING_CLASS(BadgeNotificationTelemetryProvider, + "Microsoft.WindowsAppSDK.Notifications.BadgeNotificationTelemetry", + // {c9002a02-1594-50ab-07e1-a1b60403db83} + (0xc9002a02, 0x1594, 0x50ab, 0x07, 0xe1, 0xa1, 0xb6, 0x04, 0x03, 0xdb, 0x83)); + +class BadgeNotificationTelemetry : public wil::TraceLoggingProvider +{ + IMPLEMENT_TELEMETRY_CLASS(BadgeNotificationTelemetry, BadgeNotificationTelemetryProvider); + +public: + BEGIN_COMPLIANT_MEASURES_ACTIVITY_CLASS(SetBadgeAsCount, PDT_ProductAndServicePerformance); + DEFINE_ACTIVITY_START( + NotificationTelemetryHelper& notificationTelemetryHelper, + std::wstring const& appId) noexcept try + { + TraceLoggingClassWriteStart( + SetBadgeAsCount, + _GENERIC_PARTB_FIELDS_ENABLED, + TraceLoggingWideString(appId.c_str(), "AppId"), + TraceLoggingBool(notificationTelemetryHelper.IsPackagedApp(), "IsAppPackaged"), + TraceLoggingWideString(notificationTelemetryHelper.GetAppName().c_str(), "AppName")); + } + CATCH_LOG() + END_ACTIVITY_CLASS(); + + BEGIN_COMPLIANT_MEASURES_ACTIVITY_CLASS(SetBadgeAsCountWithExpiration, PDT_ProductAndServicePerformance); + DEFINE_ACTIVITY_START( + NotificationTelemetryHelper& notificationTelemetryHelper, + std::wstring const& appId) noexcept try + { + TraceLoggingClassWriteStart( + SetBadgeAsCountWithExpiration, + _GENERIC_PARTB_FIELDS_ENABLED, + TraceLoggingWideString(appId.c_str(), "AppId"), + TraceLoggingBool(notificationTelemetryHelper.IsPackagedApp(), "IsAppPackaged"), + TraceLoggingWideString(notificationTelemetryHelper.GetAppName().c_str(), "AppName")); + } + CATCH_LOG() + END_ACTIVITY_CLASS(); + + BEGIN_COMPLIANT_MEASURES_ACTIVITY_CLASS(SetBadgeAsGlyph, PDT_ProductAndServicePerformance); + DEFINE_ACTIVITY_START( + NotificationTelemetryHelper& notificationTelemetryHelper, + std::wstring const& appId) noexcept try + { + TraceLoggingClassWriteStart( + SetBadgeAsGlyph, + _GENERIC_PARTB_FIELDS_ENABLED, + TraceLoggingWideString(appId.c_str(), "AppId"), + TraceLoggingBool(notificationTelemetryHelper.IsPackagedApp(), "IsAppPackaged"), + TraceLoggingWideString(notificationTelemetryHelper.GetAppName().c_str(), "AppName")); + } + CATCH_LOG() + END_ACTIVITY_CLASS(); + + BEGIN_COMPLIANT_MEASURES_ACTIVITY_CLASS(SetBadgeAsGlyphWithExpiration, PDT_ProductAndServicePerformance); + DEFINE_ACTIVITY_START( + NotificationTelemetryHelper& notificationTelemetryHelper, + std::wstring const& appId) noexcept try + { + TraceLoggingClassWriteStart( + SetBadgeAsGlyphWithExpiration, + _GENERIC_PARTB_FIELDS_ENABLED, + TraceLoggingWideString(appId.c_str(), "AppId"), + TraceLoggingBool(notificationTelemetryHelper.IsPackagedApp(), "IsAppPackaged"), + TraceLoggingWideString(notificationTelemetryHelper.GetAppName().c_str(), "AppName")); + } + CATCH_LOG() + END_ACTIVITY_CLASS(); + + BEGIN_COMPLIANT_MEASURES_ACTIVITY_CLASS(ClearBadge, PDT_ProductAndServicePerformance); + DEFINE_ACTIVITY_START( + NotificationTelemetryHelper& notificationTelemetryHelper, + std::wstring const& appId) noexcept try + { + TraceLoggingClassWriteStart( + ClearBadge, + _GENERIC_PARTB_FIELDS_ENABLED, + TraceLoggingWideString(appId.c_str(), "AppId"), + TraceLoggingBool(notificationTelemetryHelper.IsPackagedApp(), "IsAppPackaged"), + TraceLoggingWideString(notificationTelemetryHelper.GetAppName().c_str(), "AppName")); + } + CATCH_LOG() + END_ACTIVITY_CLASS(); +}; diff --git a/dev/Notifications/BadgeNotifications/BadgeNotifications.idl b/dev/Notifications/BadgeNotifications/BadgeNotifications.idl new file mode 100644 index 0000000000..5f23e83b57 --- /dev/null +++ b/dev/Notifications/BadgeNotifications/BadgeNotifications.idl @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +namespace Microsoft.Windows.BadgeNotifications +{ + [contractversion(1)] + apicontract BadgeNotificationsContract {}; + + // Set of predefined glyphs that can be used to represent various statuses or notifications on an application's badge + [contract(BadgeNotificationsContract, 1), feature(Feature_BadgeNotifications)] + enum BadgeNotificationGlyph + { + None, // No glyph. A blank tile appears in the badge. + Activity, // A glyph representing an activity + Alarm, // A glyph representing an alarm + Alert, // A glyph representing an alert + Attention, // A glyph representing attention + Available, // A glyph representing availability + Away, // A glyph representing being away + Busy, // A glyph representing being busy + Error, // A glyph representing an error + NewMessage, // A glyph representing a new message + Paused, // A glyph representing being paused + Playing, // A glyph representing playing + Unavailable, // A glyph representing being unavailable + }; + + // The manager class which encompasses all Badge Notification API Functionality + [contract(BadgeNotificationsContract, 1), feature(Feature_BadgeNotifications)] + runtimeclass BadgeNotificationManager + { + // Gets a Default instance of a BadgeNotificationManager + static BadgeNotificationManager Current{ get; }; + + // Updates the badge on the app's icon on taskbar to display a numeric value. + void SetBadgeAsCount(UInt32 notificationCount); + + // Updates the badge on the app's icon on taskbar to display a numeric value with an expiration time. + void SetBadgeAsCount(UInt32 notificationCount, Windows.Foundation.DateTime expiration); + + // Updates the badge on the app's icon on taskbar to display a glyph. + void SetBadgeAsGlyph(BadgeNotificationGlyph glyphValue); + + // Updates the badge on the app's icon on taskbar to display a glyph with an expiration time. + void SetBadgeAsGlyph(BadgeNotificationGlyph glyphValue, Windows.Foundation.DateTime expiration); + + // Removes the Badge Notifications for the App from Action Center + void ClearBadge(); + } +} diff --git a/dev/Notifications/BadgeNotifications/BadgeNotifications.vcxitems b/dev/Notifications/BadgeNotifications/BadgeNotifications.vcxitems new file mode 100644 index 0000000000..31607097b2 --- /dev/null +++ b/dev/Notifications/BadgeNotifications/BadgeNotifications.vcxitems @@ -0,0 +1,34 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {85d111c7-b720-4e19-a56d-03c87b953983} + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/Notifications/BaseNotifications/BaseNotification.cpp b/dev/Notifications/BaseNotifications/BaseNotification.cpp new file mode 100644 index 0000000000..732ebd4c8d --- /dev/null +++ b/dev/Notifications/BaseNotifications/BaseNotification.cpp @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include "pch.h" +#include "BaseNotification.h" + +using namespace winrt::Windows::Data::Xml::Dom; + +namespace Microsoft::Windows::BaseNotifications { + BaseNotification::BaseNotification(winrt::hstring const& payload) + { + XmlDocument xmlDocument{}; + + // We call LoadXml to verify the payload is xml + xmlDocument.LoadXml(payload); + m_payload = payload; + } + + winrt::hstring BaseNotification::Tag() + { + auto lock{ m_lock.lock_shared() }; + return m_tag; + } + + void BaseNotification::Tag(winrt::hstring const& tag) + { + auto lock{ m_lock.lock_exclusive() }; + m_tag = tag; + } + + winrt::hstring BaseNotification::Group() + { + auto lock{ m_lock.lock_shared() }; + return m_group; + } + + void BaseNotification::Group(winrt::hstring const& group) + { + auto lock{ m_lock.lock_exclusive() }; + m_group = group; + } + + uint32_t BaseNotification::Id() + { + auto lock{ m_lock.lock_shared() }; + return m_notificationId; + } + + winrt::hstring BaseNotification::Payload() + { + auto lock{ m_lock.lock_shared() }; + return m_payload; + } + + winrt::Windows::Foundation::DateTime BaseNotification::Expiration() + { + auto lock{ m_lock.lock_shared() }; + return m_expirationTime; + } + + void BaseNotification::Expiration(winrt::Windows::Foundation::DateTime const& expirationTime) + { + auto lock{ m_lock.lock_exclusive() }; + m_expirationTime = expirationTime; + } + + bool BaseNotification::ExpiresOnReboot() + { + auto lock{ m_lock.lock_shared() }; + return m_expiresOnReboot; + } + + void BaseNotification::ExpiresOnReboot(bool expiresOnReboot) + { + auto lock{ m_lock.lock_exclusive() }; + m_expiresOnReboot = expiresOnReboot; + } + + winrt::Microsoft::Windows::AppNotifications::AppNotificationPriority BaseNotification::Priority() + { + auto lock{ m_lock.lock_shared() }; + return m_priority; + } + + void BaseNotification::Priority(winrt::Microsoft::Windows::AppNotifications::AppNotificationPriority const& priority) + { + auto lock{ m_lock.lock_exclusive() }; + m_priority = priority; + } + + bool BaseNotification::SuppressDisplay() + { + auto lock{ m_lock.lock_shared() }; + return m_suppressDisplay; + } + + void BaseNotification::SuppressDisplay(bool suppressDisplay) + { + auto lock{ m_lock.lock_exclusive() }; + m_suppressDisplay = suppressDisplay; + } + + void BaseNotification::Id(uint32_t id) + { + auto lock{ m_lock.lock_shared() }; + m_notificationId = id; + } + + ::ABI::Microsoft::Internal::ToastNotifications::NotificationType BaseNotification::NotificationType() + { + auto lock{ m_lock.lock_shared() }; + return m_notificationType; + } + + void BaseNotification::NotificationType(::ABI::Microsoft::Internal::ToastNotifications::NotificationType value) + { + auto lock{ m_lock.lock_exclusive() }; + m_notificationType = value; + } +} diff --git a/dev/Notifications/BaseNotifications/BaseNotification.h b/dev/Notifications/BaseNotifications/BaseNotification.h new file mode 100644 index 0000000000..36f082fd6d --- /dev/null +++ b/dev/Notifications/BaseNotifications/BaseNotification.h @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include +#include +#include +#include + +namespace Microsoft::Windows::BaseNotifications { + struct BaseNotification + { + BaseNotification() = default; + + BaseNotification(winrt::hstring const& payload); + winrt::hstring Tag(); + void Tag(winrt::hstring const& value); + winrt::hstring Group(); + void Group(winrt::hstring const& value); + uint32_t Id(); + void Id(uint32_t id); + winrt::hstring Payload() ; + winrt::Windows::Foundation::DateTime Expiration(); + void Expiration(winrt::Windows::Foundation::DateTime const& value); + bool ExpiresOnReboot(); + void ExpiresOnReboot(bool value); + winrt::Microsoft::Windows::AppNotifications::AppNotificationPriority Priority(); + void Priority(winrt::Microsoft::Windows::AppNotifications::AppNotificationPriority const& value); + bool SuppressDisplay(); + void SuppressDisplay(bool value); + ::ABI::Microsoft::Internal::ToastNotifications::NotificationType NotificationType() ; + void NotificationType(::ABI::Microsoft::Internal::ToastNotifications::NotificationType value); + + protected: + winrt::hstring m_tag{}; + winrt::hstring m_group{}; + uint32_t m_notificationId{ 0 }; + winrt::hstring m_payload{}; + winrt::Windows::Foundation::DateTime m_expirationTime{}; + bool m_expiresOnReboot{ false }; + winrt::Microsoft::Windows::AppNotifications::AppNotificationPriority m_priority + { winrt::Microsoft::Windows::AppNotifications::AppNotificationPriority::Default }; + ::ABI::Microsoft::Internal::ToastNotifications::NotificationType m_notificationType; + bool m_suppressDisplay{ false }; + + wil::srwlock m_lock; + }; +} diff --git a/dev/Notifications/BaseNotifications/BaseNotifications.vcxitems b/dev/Notifications/BaseNotifications/BaseNotifications.vcxitems new file mode 100644 index 0000000000..f8732f5443 --- /dev/null +++ b/dev/Notifications/BaseNotifications/BaseNotifications.vcxitems @@ -0,0 +1,22 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {2bd7a1bb-d3d8-484f-9180-409d781dccf9} + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + + + + + + + + diff --git a/dev/Projections/CS/Microsoft.Windows.BadgeNotifications.Projection/Microsoft.Windows.BadgeNotifications.Projection.csproj b/dev/Projections/CS/Microsoft.Windows.BadgeNotifications.Projection/Microsoft.Windows.BadgeNotifications.Projection.csproj new file mode 100644 index 0000000000..5fd9b2a649 --- /dev/null +++ b/dev/Projections/CS/Microsoft.Windows.BadgeNotifications.Projection/Microsoft.Windows.BadgeNotifications.Projection.csproj @@ -0,0 +1,59 @@ + + + net6.0-windows10.0.17763.0 + 10.0.17763.0 + x64;x86;arm64 + AnyCPU + false + + + + true + true + + + + + 8305 + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + Microsoft.Windows.BadgeNotifications + 10.0.17763.0 + false + + + + + pdbonly + true + + + + + + + + + + + + + $(OutDir)..\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.BadgeNotifications.winmd + true + + + diff --git a/dev/PushNotifications/PushNotificationUtility.h b/dev/PushNotifications/PushNotificationUtility.h index ae797af578..30d17227fa 100644 --- a/dev/PushNotifications/PushNotificationUtility.h +++ b/dev/PushNotifications/PushNotificationUtility.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #pragma once @@ -23,7 +23,7 @@ namespace winrt::Microsoft::Windows::PushNotifications::Helpers inline constexpr std::wstring_view c_argumentCommandString = L"Arguments"; inline constexpr std::wstring_view c_executableCommandString = L"Executable"; - inline std::string WideStringToUtf8String(_In_ winrt::hstring const& utf16string) + inline std::string WideStringToPayloadUtf8String(_In_ winrt::hstring const& utf16string) { int size = WideCharToMultiByte( CP_UTF8, diff --git a/dev/PushNotifications/externs.h b/dev/PushNotifications/externs.h index 14753585fb..87f43c4aef 100644 --- a/dev/PushNotifications/externs.h +++ b/dev/PushNotifications/externs.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #pragma once @@ -10,6 +10,7 @@ inline const winrt::hstring STORED_PUSH_MANAGER_KEY = L"StoredPushManagerKey"; inline const winrt::hstring STORED_APPNOTIFICATION_MANAGER_KEY = L"StoredAppNotificationManagerKey"; +inline const winrt::hstring STORED_BADGENOTIFICATION_MANAGER_KEY = L"StoredBadgeNotificationManagerKey"; inline const DWORD c_receiveArgsTimeoutInMSec{ 2000 }; inline NotificationTelemetryHelper g_telemetryHelper{}; diff --git a/dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj b/dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj index 62e67cef13..4ffc28bcad 100644 --- a/dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj +++ b/dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj @@ -102,6 +102,8 @@ + +