superloubou
superloubou
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
the windows.ui.notifications.management api is also not listed under the list of apis which require a package identity
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
and shouldnt rely on any ui/gui packages other than windows.ui
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
my version of windows is above the minimum
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
nowhere in any documentation does it suggest that i need anything more than the windows 10 sdk
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
but cant seem to bind an event handler
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
it can get the list of notifications perfectly fine
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
ive changed it to .net 8.0 targeting windows 10.0.19041.0 using the windows sdk
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
using Windows.UI.Notifications.Management;
using Windows.UI.Notifications;
using Windows.Foundation.Metadata;



var listener = UserNotificationListener.Current;

if (!ApiInformation.IsTypePresent("Windows.UI.Notifications.Management.UserNotificationListener"))
{
Console.WriteLine("API can't be found");
}

var access_status = listener.GetAccessStatus();

if (access_status == UserNotificationListenerAccessStatus.Allowed)
{
Console.WriteLine("Allowed");
}
else
{
Console.WriteLine("Not allowed");
}

var notifications = await listener.GetNotificationsAsync(NotificationKinds.Toast);

Console.WriteLine(notifications.Count());

try
{
listener.NotificationChanged += Listener_NotificationChanged;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}

void Listener_NotificationChanged(UserNotificationListener sender, UserNotificationChangedEventArgs args)
{
Console.WriteLine("Notification received");
}
using Windows.UI.Notifications.Management;
using Windows.UI.Notifications;
using Windows.Foundation.Metadata;



var listener = UserNotificationListener.Current;

if (!ApiInformation.IsTypePresent("Windows.UI.Notifications.Management.UserNotificationListener"))
{
Console.WriteLine("API can't be found");
}

var access_status = listener.GetAccessStatus();

if (access_status == UserNotificationListenerAccessStatus.Allowed)
{
Console.WriteLine("Allowed");
}
else
{
Console.WriteLine("Not allowed");
}

var notifications = await listener.GetNotificationsAsync(NotificationKinds.Toast);

Console.WriteLine(notifications.Count());

try
{
listener.NotificationChanged += Listener_NotificationChanged;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}

void Listener_NotificationChanged(UserNotificationListener sender, UserNotificationChangedEventArgs args)
{
Console.WriteLine("Notification received");
}
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
also it would help me if you could point me to which gui package specifically you are referring to
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
I dont really understand this since windows.ui.notifications.management is part of the windows 10 sdk. UserNotificationListener.GetNotificationsAsync works outside of a packaging project but UserNotificationListener.GetNotification doesnt
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
according to this
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
the windows.ui.notifcations.management api isnt listed on the list of apis that only work in packaging projects
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
@TeBeCo sorry to revive the thread but im not trying to use this in a gui. ive managed to get this to work by using a windows packaging project but i still dont understand why its not possible to work in a console app
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
ive read every relevant stack overflow post on this specific issue and the only one that got me anywhere was running it from within an msix package app but i dont understand why i have to do this to access the api? ive seen other people online access the winrt api straight from a .net console app or even a python app.
32 replies
CC#
Created by superloubou on 7/9/2024 in #help
Element not found error while trying to use UserNotficationListener
error happens on the listener.NotificationChanged line
32 replies