Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the payload if it was processed already. #2350

Merged
merged 1 commit into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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