From a5645498ff006f44793f3a5a91980ea83a1d7208 Mon Sep 17 00:00:00 2001 From: Paul Purifoy <33183370+pmpurifoy@users.noreply.github.com> Date: Fri, 1 Apr 2022 12:44:16 -0700 Subject: [PATCH] Return the payload if it was processed already. (#2350) --- dev/AppNotifications/AppNotificationManager.cpp | 6 ++++++ dev/PushNotifications/PushNotificationManager.cpp | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/dev/AppNotifications/AppNotificationManager.cpp b/dev/AppNotifications/AppNotificationManager.cpp index 0971e44bce..ec7bdeec60 100644 --- a/dev/AppNotifications/AppNotificationManager.cpp +++ b/dev/AppNotifications/AppNotificationManager.cpp @@ -81,6 +81,12 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation winrt::Windows::Foundation::IInspectable AppNotificationManager::Deserialize(winrt::Windows::Foundation::Uri const& /* uri */) { + // Return the args if they are available. + if (m_activatedEventArgs) + { + return m_activatedEventArgs; + } + THROW_HR_IF(HRESULT_FROM_WIN32(ERROR_TIMEOUT), !m_waitHandleForArgs.wait(c_receiveArgsTimeoutInMSec)); return m_activatedEventArgs; } diff --git a/dev/PushNotifications/PushNotificationManager.cpp b/dev/PushNotifications/PushNotificationManager.cpp index 0d3726c8fe..e688a9397b 100644 --- a/dev/PushNotifications/PushNotificationManager.cpp +++ b/dev/PushNotifications/PushNotificationManager.cpp @@ -164,6 +164,12 @@ namespace winrt::Microsoft::Windows::PushNotifications::implementation winrt::Windows::Foundation::IInspectable PushNotificationManager::Deserialize(winrt::Windows::Foundation::Uri const& uri) { + // Return the args if they are available. + if (m_backgroundTaskArgs) + { + return m_backgroundTaskArgs; + } + winrt::Microsoft::Windows::PushNotifications::PushNotificationReceivedEventArgs eventArgs{ nullptr }; // All packaged processes are triggered through COM via Long Running Process or the Background Infra OS component @@ -183,6 +189,7 @@ namespace winrt::Microsoft::Windows::PushNotifications::implementation // Convert escaped components to its normal content from the conversion done in the Long Running Process (see NotificationListener.cpp) auto payloadAsWstring = winrt::Windows::Foundation::Uri::UnescapeComponent(pair.Value()); eventArgs = winrt::make(payloadAsWstring); + m_backgroundTaskArgs = eventArgs; } }