So, what I need to get:
To trigger the alarm after it is installed.

What I get:
If the application is not closed, then the alarm clocks work as expected. But if the application is closed, the stack of these guns will be cleared. I checked it this way - I set the alarm, I was convinced of its work when the application was running, I started it again and closed the application, the response time comes, and there are no push notifications. Alarm clock so:

ToastContent content = new ToastContent() { Scenario = ToastScenario.Alarm, Visual = new ToastVisual() { TitleText = new ToastText() { Text = "Пора на работу!\n Начало в " + appointment.StartTime.ToString() } }, Audio = new ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.Looping.Alarm") }, Actions = new ToastActionsCustom() { Buttons = { new ToastButtonSnooze(), new ToastButtonDismiss() } }, }; var toastNotifier = ToastNotificationManager.CreateToastNotifier(); ScheduledToastNotification stn = new ScheduledToastNotification(content.GetXml(), alarmTime, TimeSpan.FromMinutes(10), 3); stn.Id = appointment.AppointmentID; ToastNotificationManager.CreateToastNotifier().AddToSchedule(stn); 
  • If I don’t find a solution to clearing the stack with the guns when the application is closed, then I’ll do this - instead of adding a push to the stack, I’ll retry the background task trigger. And when the trigger works right there to show a toast. - D. Daniel
  • IMHO, without a background task can not do - Andrew NOP

1 answer 1

In my opinion, you need to register a background task in the manifest and specify await BackgroundExecutionManager.RequestAccessAsync(); in App.xaml.cs await BackgroundExecutionManager.RequestAccessAsync();