c# – 在Windows Phone 8.1 Universal Store App中触发警报?
这似乎在
Windows 8.1 Universal Store App中正常工作,但在Windows Phone 8.1 Universal Store App中却没有.这可以调整为适用于Windows手机,就像它对Windows平板电脑一样吗?
XML文件: <toast duration="long" launch="alarm(eb6c47a8-e5e2-40d0-bc4e-3aa957f36484)"> <visual> <binding template="ToastImageAndText04"> <text id="1">Alarm App</text> <text id="2">Alarm Test</text> <text id="3">Time to wake up!</text> </binding> </visual> <audio loop="true" src="ms-winsoundevent:Notification.Looping.Alarm2" /> <commands scenario="alarm"> <command id="snooze" /> <command id="dismiss" /> </commands> </toast> 通知类: public class Notification { public async Task CreateNotification() { StorageFolder storageFolder = Package.Current.InstalledLocation; var toast = await storageFolder.GetFileAsync("toast.xml"); var xml = await FileIO.ReadTextAsync(toast); NotifyScheduled(xml); } private void NotifyScheduled(string toast,int delay = 5,int snooze = 300,int maxSnoozeCount = 3) { XmlDocument document = new XmlDocument(); document.LoadXml(toast); var notifier = ToastNotificationManager.CreateToastNotifier(); var scheduledToast = new ScheduledToastNotification(document,DateTime.Now.AddSeconds(delay),TimeSpan.FromSeconds(snooze),(uint)maxSnoozeCount); notifier.AddToSchedule(scheduledToast); } } 并在Phone的xaml.cs页面中实现: var note = new Notification(); note.CreateNotification(); 结果应如下所示: 但它目前只是像这样做一个常规的吐司通知(在你根据需要解雇或打盹之前不会发出警报): 就像我提到的,我可以让它在Windows平板电脑(Windows 8.1)中正常工作,它看起来像这样: 编辑:值得注意的是,如果您的平板电脑设备没有将您的应用程序指定为默认警报应用程序(只能分配一个),则不会显示“暂停/关闭”按钮.但是,在Windows Phone 8.1中,没有选项可以定义默认警报应用程序的内容. 解决方法
不幸的是(因为我也需要警报),目前似乎不可能.
这是一篇关于Windows Phone 8.0和8.1中的功能的非常好的文章,以及它们如何映射以及可以在哪里执行的操作:http://msdn.microsoft.com/en-us/library/dn642486(v=vs.105).aspx 有一节(第一节)叫
在其中,你可以看到
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |