PUSH not showing when App is open

Posted by  ezra heywood
 1779  View(s)
Rate this:
My application receives push notifications well when the application is closed. But when the app is running, I get nothing. This is the same code that I have used in previous apps with out any problems, those were on WindowsPhone8 and the new apps are running on WindowsPhone8.1 devices.

I used this Push Tutorial when I made the original app. I do have the line that says add this if you want to receive notifications while the app is open.

If the 8.1 update has done something to the push notifications that would be good to know. Anything else would also be appreciated.

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<NotificationChannelUriEventArgs>(
    pushChannel.ErrorOccurred += 
      new EventHandler<NotificationChannelErrorEventArgs>(
    // Register for this notification only if you need to receive 
    // the notifications while your application is running.
    pushChannel.ShellToastNotificationReceived += 
      new EventHandler<NotificationEventArgs>(
    // Bind this new channel for toast events.

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(
        System.Globalization.CompareOptions.IgnoreCase) == 0)
            relativeUri = e.Collection[key];

  1. Re: PUSH not showing when App is open

    Toasts aren't expected to display when the app is in the foreground. The app is expected to show its own UI, if needed (your snippet doesn't show anything). This is what the ShellToastNotificationReceived event is for: it fires when a toast notification arrives instead of the toast showing up. Can you confirm that ShellToastNotificationReceived isn't raised when you expect the toast? It should be. Can you confirm that it is registered for and received (or not) in the debugger? See msdn.microsoft.com/en-us/library/windows/apps/…

    Before the 8.1 Update, when an open app received a PUSH, the toast would still show. I just did some testing, and sure enough, the "PushChannel_ShellToastNotificationReceived" event is still being fired, but the toast not showing. I guess this just means I need to handle it different. If you want to turn that into an answer,