您好,我希望我的应用程序导航到一个页面,当我收到推吐司通知。我的代码如下:
ParsePush.ToastNotificationReceived += OnPushNotification;这是为了处理推流事件
private async void OnPushNotification(object sender, Windows.Networking.PushNotifications.PushNotificationReceivedEventArgs e)
{
var AdFrame = Window.Current.Content as Frame;
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
if (localSettings.Values.ContainsKey("Suspended"))
{
String value = localSettings.Values["Suspended"].ToString();
if (value != null)
{
if (value == "false")
{
AdFrame.Navigate(typeof(Ad));
}
}
}
}我在var AdFrame = Window.Current.Content as Frame;收到一个空引用错误
我在App.xaml.cs .I中添加了这段代码,只是想从当前页面导航到广告页面,无论哪个页面可能处于活动状态。我是windows的新手,任何帮助都将不胜感激。
发布于 2015-07-16 23:56:46
您需要显示toast通知,而不是:
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(
ToastTemplateType.ToastImageAndText02);
XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
stringElements.Item(0).AppendChild(toastXml.CreateTextNode("Hello world!"));
IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
XmlAttribute launchAttribute = toastXml.CreateAttribute("launch");
launchAttribute.Value = "pass data here"; // TODO: pass data here
toastNode.Attributes.SetNamedItem(launchAttribute);
ToastNotification toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(toast);当用户点击吐司通知,你就可以处理发布会应用,然后读取数据。
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
// ...
MainPage page = rootFrame.Content as MainPage;
page.ParseData(e.Arguments);
}https://stackoverflow.com/questions/31450850
复制相似问题