【发布时间】:2015-01-26 13:49:43
【问题描述】:
我正在尝试学习 MVVM Light 并将其用于我的 Windows Phone 8 应用程序。它工作得很好,但我找不到任何教程或示例如何使用带有 MVVM 模式的推送通知。
在我的 MainPage 中,我设置了 HttpNotificationChannel 并且我正在接收通知:
void PushChannel_ShellToastNotificationReceived(object sender, NotificationEventArgs e)
{
StringBuilder message = new StringBuilder();
string relativeUri = string.Empty;
message.AppendFormat("Received Toast {0}:\n", DateTime.Now.ToShortTimeString());
// Parse out the information that was part of the message.
foreach (string key in e.Collection.Keys)
{
message.AppendFormat("{0}: {1}\n", key, e.Collection[key]);
if (string.Compare(
key,
"wp:Param",
System.Globalization.CultureInfo.InvariantCulture,
System.Globalization.CompareOptions.IgnoreCase) == 0)
{
relativeUri = e.Collection[key];
}
}
// Display a dialog of all the fields in the toast.
//Dispatcher.BeginInvoke(() => MessageBox.Show(message.ToString()));
}
现在我不知道该怎么办。我会收到大约 5 种不同类型的通知,它们应该将应用导航到应用中的不同页面或刷新页面(或者可能将一些数据保存到存储中)。我怎样才能做到这一点?当我搜索时,我在 mvvm light 中找到了一些消息传递系统。我可以用它来通知吗?我应该使用哪些类型的消息?您能否给我一些示例代码或指向我的教程(文章/视频)。谢谢
【问题讨论】:
标签: c# windows-phone-8 mvvm push-notification mvvm-light