I need to trigger a background task from interactive toast notification by pressing action button. i don't know what i'm doing wrong. i'm able to register a task and see it in visual studio. even i can debug it (debuger jumps to MyToastNotificationBackgroundTask.Run function but argument IBackgroundTaskInstance taskInstance is empty object), clicking on a button never runs the task or at least debuger dosn't show it.
I'm registering a background task like this
var builder = new BackgroundTaskBuilder();
builder.Name = "MyToastNotificationBackgroundTask";
builder.TaskEntryPoint = "Tasks.MyToastNotificationBackgroundTask";
builder.SetTrigger(new ToastNotificationActionTrigger());
BackgroundTaskRegistration task = builder.Register();
showing 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 app manifest
<Extensions>
<Extension Category="windows.backgroundTasks" EntryPoint="Tasks.MyToastNotificationBackgroundTask">
<BackgroundTasks>
<Task Type="systemEvent" />
</BackgroundTasks>
</Extension>
</Extensions>
in toast template xml action buttons are
<actions>
<input id="message" type="text" placeholderContent="200" />
<action activationType="background" content="Count" arguments="count" />
</actions>
background task itsetf
namespace Tasks
{
public sealed class MyToastNotificationBackgroundTask : IBackgroundTask
{
public void Run(IBackgroundTaskInstance taskInstance)
{
var details = taskInstance.TriggerDetails as ToastNotificationActionTriggerDetail;
...
}
}
}
i can't understand how specifying activationype="background" on a notification templates action button is relating to MyToastNotificationBackgroundTask task? i can't find relevant info on that.
somebody please share your knowledge. maybe you have a working example or smf. any help will be appreciated. thanks in advance.