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
Asked
Active
Viewed 289 times
1 Answers
0
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

Nico Zhu
- 32,367
- 2
- 15
- 36
-
currently i use background task to generate a toast, but when toast has a button and i click on it, my background application opens, i don't want that to happen, is there anything i can do to make it happen? – Eduardo Aug 27 '21 at 13:49
-
background application ? if you set `ToastActivationType.Background` it only trigger your background but not launch your app. – Nico Zhu Sep 03 '21 at 06:57
-
yesss, but when i click in notification Action (button), the app opens. I would like the application not to open, but at the same time make a logic when the user clicks on the notification action (button) – Eduardo Sep 03 '21 at 13:36