Hello,
i have problems handling/evaluating the user reaction (button pressed...) from a ToastNotification.
What I have tried:
Tried this code:
ToastContentBuilder tcb = new ToastContentBuilder();
tcb.AddArgument("action", "viewConversation");
tcb.AddArgument("conversationId", 9813);
tcb.AddText("Installation will be executed in 2 minutes");
tcb.AddAppLogoOverride(new Uri(PROGRAM_PATH + "LDNotifyIcon.png"), ToastGenericAppLogoCrop.Circle);
tcb.AddHeroImage(new Uri(PROGRAM_PATH + "LDNotifyHero.png"));
tcb.AddToastInput(new ToastSelectionBox("time")
{
DefaultSelectionBoxItemId = "60",
Items =
{
new ToastSelectionBoxItem("1", "1 minute"),
new ToastSelectionBoxItem("5", "5 minutes"),
new ToastSelectionBoxItem("10", "10 minutes"),
new ToastSelectionBoxItem("60", "1 hour"),
new ToastSelectionBoxItem("240", "4 hours")
}
});
tcb.AddButton(new ToastButton()
.SetContent("Start now")
.AddArgument("action", "startNow")
.SetBackgroundActivation());
tcb.AddButton(new ToastButton()
.SetContent("Snooze")
.AddArgument("action", "snooze")
.SetBackgroundActivation());
tcb.SetToastScenario(ToastScenario.Reminder);
tcb.GetToastContent();
toast = new ToastNotification(tcb.GetXml());
toast.Activated += HandleToastActivation;
toast.Tag = "RebootNotifier";
ToastNotificationManager.CreateToastNotifier().Show(toast);
private static void HandleToastActivation(ToastNotification sender, object args)
{
Log("HandleToastActivation reached");
}
The toast shows up, but when i press "Snooze", the void "HandleToastActivation" is never reached.
Alternatively i tried in the Startup function:
ToastNotificationManagerCompat.OnActivated += toastArgs =>
{
ToastArguments args = ToastArguments.Parse(toastArgs.Argument);
string strAction = args.Get("action");
ValueSet userInput = toastArgs.UserInput;
userInput.TryGetValue("time", out object oTime);
...
}
Again.. the code lines are never reached.
I have a wpf application, included a packaging project, finally the project will be published as an MXIS Installation package file.
Could anyone please help me how i can get/handle the user input from the toast notification?
That would be great
Thanks a lot in advance !