forum

Home / DeveloperSection / Forums / PUSH not showing when App is open

PUSH not showing when App is open

Anonymous User 2325 24-Apr-2015
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_ChannelUriUpdated);
    pushChannel.ErrorOccurred += 
      new EventHandler<NotificationChannelErrorEventArgs>(
         PushChannel_ErrorOccurred);
    // Register for this notification only if you need to receive 
    // the notifications while your application is running.
    pushChannel.ShellToastNotificationReceived += 
      new EventHandler<NotificationEventArgs>(
         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];
        }

    }
}

Updated on 24-Apr-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By