Samples/Notifications/Push/cpp-console-unpackaged/cpp-console-unpackaged.cpp
// Subscribe to an event which will get signaled whenever a foreground notification arrives.

Subscribe to an event which will get signaled whenever a foreground notification arrives.
Subscribe to an event which will get signaled whenever a foreground notification arrives .
void SubscribeForegroundEventHandler()
{
    winrt::event_token token{ PushNotificationManager::Default().PushReceived([](auto const&, PushNotificationReceivedEventArgs const& args)
    {
        auto payload{ args.Payload() };
        std::string payloadString(payload.begin(), payload.end());
        std::cout << "\nPush notification content received in the FOREGROUND: " << payloadString << std::endl;
    }) };
}
void SubscribeForegroundEventHandler ( ) { winrt :: event_token token { PushNotificationManager :: Default ( ) . PushReceived ( [ ] ( auto const & , PushNotificationReceivedEventArgs const & args ) { auto payload { args . Payload ( ) } ; std :: string payloadString ( payload . begin ( ) , payload . end ( ) ) ; std :: cout << " \n " << payloadString << std :: endl ; } ) } ; }
Subscribe to an event which will get signaled whenever a foreground notification arrives.
Subscribe to an event which will get signaled whenever a foreground notification arrives .