0
정기적으로 토스트 알림을하고 싶습니다.예정된 토스트 알림 UWP
코드 :
public sealed partial class MainPage : Page
{
const string TOAST = @"
<toast>
<visual>
<binding template=""ToastTest"">
<text>Hello Toast</text>
</binding>
</visual>
<audio src =""ms-winsoundevent:Notification.Mail"" loop=""true""/>
</toast>";
public MainPage()
{
this.InitializeComponent();
}
private void btnNotification_Click(object sender, RoutedEventArgs e)
{
var when = DateTime.Now.AddSeconds(6);
var offset = new DateTimeOffset(when);
Windows.Data.Xml.Dom.XmlDocument xml = new Windows.Data.Xml.Dom.XmlDocument();
xml.LoadXml(TOAST);
ScheduledToastNotification toast = new ScheduledToastNotification(xml, offset, TimeSpan.FromSeconds(5), 5);
toast.Id = "IdTostone";
toast.Tag = "NotificationOne";
ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
}
}
오류는 스크립트가 발생했습니다 : 잘못된 매개 변수를. .
어디서 실수입니까?
미리 감사드립니다.
하지만 어떻게 시간의 제한없이, 예를 들어, 매일, 당신은 반복을 만들합니까? – LightGreen
불행히도이를 수행하는 편리한 방법이 없습니다. 동시에 토스트를 보내야 할 경우 매일 한 토스트 알림을 예약 할 수 있습니다. for (int i = 0; i <31; i ++) ScheduledToastNotification 토스트 = new 모든 토스트에 대해 하루 중 시간을 변경해야하는 경우 ToastNotificationManager 클래스를 사용하여 토스트 일정에서 모두 제거하고 새로운 일정을 만듭니다. (ToStringNotificationNotification (xml, offset + TimeSpan.FromDays (i)); 적절한 시간에 토스트. –
@ LightGreen, 좀 더 자세한 설명이 필요하면 별도의 질문을 만들어야합니다. –