从我WP8后台代理我这是工作的罚款正常ShellToast。发送从后台代理沉默土司的Windows Phone 8.1的Silverlight
但如今随着WP8.1我想给在特定时段(夜间)一个安静的敬酒的能力,它应该只在在这几个小时通知中心显示出来。 我一直在关注this guide,但它似乎并没有在所有的工作。敬酒没有显示出来......
任何人都已经得到了这工作还没有?
感谢
我的代码:
public MainPage()
{
InitializeComponent();
SendToast();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
SendToast();
}
private void SendToast()
{
// Using the ToastText02 toast template.
ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;
// Retrieve the content part of the toast so we can change the text.
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
//Find the text component of the content
XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
// Set the text on the toast.
// The first line of text in the ToastText02 template is treated as header text, and will be bold.
toastTextElements[0].AppendChild(toastXml.CreateTextNode("Heading"));
toastTextElements[1].AppendChild(toastXml.CreateTextNode("Body"));
// Set the duration on the toast
IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
((XmlElement)toastNode).SetAttribute("duration", "long");
// Create the actual toast object using this toast specification.
ToastNotification toast = new ToastNotification(toastXml);
toast.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(3600);
// Set SuppressPopup = true on the toast in order to send it directly to action center without
// producing a popup on the user's phone.
toast.SuppressPopup = false;
// Send the toast.
ToastNotificationManager.CreateToastNotifier().Show(toast);
}
您是否在清单中启用了Toast通知?否则,有些可能会很酷,因为给定的指南很好,我们不能发布比那里写的更好的代码+解释。 – sibbl
你的意思是ID_CAP_PUSH_NOTIFICATION?没有烤面包,对吧? – robertk
@robertftw请澄清当前代码中哪些内容不起作用。 –