我通过 Toast 通知为应用程序编写了 future 提醒,我可以通过 BackgroundTask 每次提醒
但我想每天提醒一次,例如:每天下午 4 点
我搜索并获取有关闹钟和提醒的信息不在 Windows Phone 8.1 中
那么有别的办法吗?
抱歉我的英语不好
最佳答案
您可以使用预定的 toast 通知在特定时间触发 toast。这不要求应用程序在 toast 触发时运行,仅当 toast 被安排时。
您需要为每一天安排单独的 toast ,因为没有自动重复。如果用户可能会频繁运行该应用程序,那么您可以在接下来的 30 天左右安排该应用程序运行的时间。另一种选择是设置 MaintainanceTrigger 后台任务,以在插入应用程序时每隔一段时间安排接下来的 30 天。
// Today, 4:00pm
DateTime now = DateTime.Now;
DateTime dueTime = new DateTime(now.Year, now.Month, now.Day, 16, 0, 0);
ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();
for(int i=0;i<30;i++)
{
dueTime.AddDays(1);
XmlDocument toastXml = SetupMyToast(dueTime);
ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, dueTime);
toastNotifier.AddToSchedule(scheduledToast);
}
有关详细信息,请参阅 Quickstart: Sending a toast notification (XAML) and How to schedule a toast notification
关于c# - Windows Phone 8.1 中的警报代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25989590/