從我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請澄清當前代碼中哪些內容不起作用。 –