Pregunta

I'm trying to send push notifications to my widows phone 8 app (Tile notification). This is the response from MPNS: notification status : suppressed notificationChannelStatus :Active, deviceConnectionStatus:Connected. I have checked the server response codes, and I found the following explanation:

The push notification was received and dropped by the Push Notification Service. The Suppressed status can occur if the notification type was not enabled by calling BindToShellTile or BindToShellToast in the client application

This is my code in client side and I am calling BindToShellTile method - it is getting invoked the first time the app is installed.

HttpNotificationChannel pushChannel;
string channelName = "TileSampleChannel";
pushChannel = HttpNotificationChannel.Find(channelName);
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);  
    pushChannel.Open();               
    pushChannel.BindToShellTile();
} else {          
    pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
    pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);                    
    System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
    MessageBox.Show(String.Format("Channel Uri is {0}",
    pushChannel.ChannelUri.ToString())); 
}

And I am able to get the channel URI successfully. Why am I always getting suppressed state? I have tested this on device and I have checked that battery is not low. The tile is also pinned to start screen.

This is my XML

 string tileMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<wp:Notification xmlns:wp=\"WPNotification\">" +
                    "<wp:Tile>" +
                      "<wp:BackgroundImage>" + TextBoxBackgroundImage.Text + "</wp:BackgroundImage>" +
                      "<wp:Count>" + TextBoxCount.Text + "</wp:Count>" +
                      "<wp:Title>" + TextBoxTitle.Text + "</wp:Title>" +
                      "<wp:BackBackgroundImage>" + TextBoxBackBackgroundImage.Text + "</wp:BackBackgroundImage>" +
                      "<wp:BackTitle>" + TextBoxBackTitle.Text + "</wp:BackTitle>" +
                      "<wp:BackContent>" + TextBoxBackContent.Text + "</wp:BackContent>" +
                   "</wp:Tile> " +
                "</wp:Notification>";
¿Fue útil?

Solución

Verify that your notification content length,content type and headers are correct.

For Tile notifications you need the following headers :

sendNotificationRequest.Headers.Add("X-WindowsPhone-Target", "token");
sendNotificationRequest.Headers.Add("X-NotificationClass", "1");

and before headers, set the content length and type as follows :

sendNotificationRequest.ContentLength = notificationMessage.Length;
sendNotificationRequest.ContentType = "text/xml";

If you don't specify the headers correctly that can make Notification Status as Suppressed. This might be useful.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top