Skip to content

Commit

Permalink
Return the payload if it was processed already. (#2350)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmpurifoy authored Apr 1, 2022
1 parent 4b9e16e commit a564549
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dev/AppNotifications/AppNotificationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions dev/PushNotifications/PushNotificationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<winrt::Microsoft::Windows::PushNotifications::implementation::PushNotificationReceivedEventArgs>(payloadAsWstring);
m_backgroundTaskArgs = eventArgs;
}
}

Expand Down

0 comments on commit a564549

Please sign in to comment.