I need to start a background task from an interactive toast notification by clicking an action button. I do not know what I am doing wrong. I can register the task and watch it in visual studio. even I can debug it (debuger goes to the MyToastNotificationBackgroundTask.Run function, but the IBackgroundTaskInstance taskInstance argument is an empty object), clicking on the button never starts the task, or at least debuger dosn't show it.
I am registering a background job like this
var builder = new BackgroundTaskBuilder();
builder.Name = "MyToastNotificationBackgroundTask";
builder.TaskEntryPoint = "Tasks.MyToastNotificationBackgroundTask";
builder.SetTrigger(new ToastNotificationActionTrigger());
BackgroundTaskRegistration task = builder.Register();
display notification
ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();
ScheduledToastNotification myToastNotificaton = new ScheduledToastNotification(this.myToastXml, DateTime.Now.AddMinutes(1), TimeSpan.FromMinutes(60), 2);
myToastNotificaton .Id = "toast_54ahk36s";
toastNotifier.AddToSchedule(myToastNotificaton);
in the application manifest
<Extensions>
<Extension Category="windows.backgroundTasks" EntryPoint="Tasks.MyToastNotificationBackgroundTask">
<BackgroundTasks>
<Task Type="systemEvent" />
</BackgroundTasks>
</Extension>
</Extensions>
in action buttons xml toast template
<actions>
<input id="message" type="text" placeholderContent="200" />
<action activationType="background" content="Count" arguments="count" />
</actions>
itsetf background task
namespace Tasks
{
public sealed class MyToastNotificationBackgroundTask : IBackgroundTask
{
public void Run(IBackgroundTaskInstance taskInstance)
{
var details = taskInstance.TriggerDetails as ToastNotificationActionTriggerDetail;
...
}
}
}
, = "" , MyToastNotificationBackgroundTask? .
-, , . , smf. . .