Can i create a "OnClick" in toast action from UWP?

417 Views Asked by At

I need to catch in background this click, when i use OnActivated, the app open. I don't want the app to open when I click on the action

1

There are 1 best solutions below

3
On

Sure UWP notification active type contains Background, that means you could call registered background task to process the corresponding content instead of starting the foreground app after click the toast.

UWP can set the notification active type when sending a notification:

var content = new ToastContent
{
    Launch = "...",
    ActivationType = ToastActivationType.Background
    
};
var notifier = ToastNotificationManager.CreateToastNotifier();
var notification = new ToastNotification(content.GetXml());
notifier.Show(notification);

For detailed information about background notifications, you can refer to these documents:

For using above ToastContent api please install Microsoft.Toolkit.Uwp.Notifications nuget package* for more detail please refer to Send a local toast notification from C# apps