App打开时PUSH不显示

应用程序关闭时,我的应用程序会很好地接收推送通知 但是当应用程序运行时,我什么都没得到。 这与我以前在没有任何问题的应用程序中使用的代码相同,这些代码在WindowsPhone8上,而新的应用程序在WindowsPhone8.1设备上运行。

我在创建原始应用程序时使用了这个Push Tutorial 。 如果您想在应用程序打开时接收通知,我确实有一行说明添加此项。

如果8.1更新已经对推送通知做了一些很好的了解。 其他任何东西也将不胜感激。

HttpNotificationChannel pushChannel; string channelName = "PushChannel"; pushChannel = HttpNotificationChannel.Find(channelName); //Push Notifications if (pushChannel == null) { pushChannel = new HttpNotificationChannel(channelName); //// Register for all the events before attempting to open the channel. pushChannel.ChannelUriUpdated += new EventHandler( PushChannel_ChannelUriUpdated); pushChannel.ErrorOccurred += new EventHandler( PushChannel_ErrorOccurred); // Register for this notification only if you need to receive // the notifications while your application is running. pushChannel.ShellToastNotificationReceived += new EventHandler( PushChannel_ShellToastNotificationReceived); pushChannel.Open(); // Bind this new channel for toast events. pushChannel.BindToShellToast(); } else... void PushChannel_ShellToastNotificationReceived(object sender, NotificationEventArgs e) { string relativeUri = string.Empty; // Parse out the information that was part of the message. foreach (string key in e.Collection.Keys) { if (string.Compare( key, "wp:Param", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.CompareOptions.IgnoreCase) == 0) { relativeUri = e.Collection[key]; } } } 

Rob Caplan:

当应用程序位于前台时,预计不会显示Toasts。 如果需要,应用程序应显示自己的UI(您的代码段不显示任何内容)。 这就是ShellToastNotificationReceived事件的用途:当Toast通知到达而不是出现Toast时,它会触发。 您是否可以确认在您期待吐司时未提出ShellToastNotificationReceived? 它应该是。 您能否确认它已在调试器中注册和接收(或未接收)? 请参阅msdn.microsoft.com/en-us/library/windows/apps/ …

我:

在8.1更新之前,当打开的应用程序收到PUSH时,toast仍会显示。 我刚做了一些测试,果然,“PushChannel_ShellToastNotificationReceived”事件仍然被触发,但吐司没有显示。 我想这只是意味着我需要处理它不同。 如果你想把它变成一个答案,我可以奖励它。