locked
Push Notification dropped

    Question

  • Hey, i'm developping a push notification client with a server in Asp .net, all in C#

    Here my code for sending the push notification:

                          

    bool result = false;

                try
                {
                    string rawType = "wns/";
                    string notificationContent = String.Empty;

                    switch (pushType)
                    {
                        case PushType.Badge:
                            rawType += "badge";
                            notificationContent = String.Format("<?xml version='1.0' encoding='utf-8'?><badge value=\"{0}\"/>", text);
                            break;
                        case PushType.Tile:
                            rawType += "tile";
                            notificationContent = String.Format("<?xml version='1.0' encoding='utf-8'?><tile><visual lang=\"en-US\">" +
                            "<binding template=\"TileWideSmallImageAndText03\"><image id=\"1\" src=\"{0}\"/><text id=\"1\">{1}</text>" +
                            "</binding></visual></tile>", imageSource, text);
                            break;
                        case PushType.Toast:
                            rawType += "toast";
                            notificationContent = String.Format("<?xml version='1.0' encoding='utf-8'?><toast launch='{0}'><visual>" +
                            "<binding template='ToastImageAndText01'><image id='1' src='{1}' alt='Placeholder image' />" +
                            "<text id='1'>{2}</text></binding></visual></toast>", "My Launch" ,imageSource, text);
                            break;
                        default:
                            break;
                    }

                    var subscriptionUri = new Uri(_uri);
                    WebRequest webRequest = HttpWebRequest.Create(subscriptionUri);
                    HttpWebRequest request = webRequest as HttpWebRequest;
                    webRequest.Method = "POST";
                    request.ContentType = "text/xml";
                    request.Headers = new WebHeaderCollection();
                    request.Headers.Add("X-WNS-Type", rawType);
                    request.Headers.Add("X-WNS-RequestForStatus", "true");
                    request.Headers.Add("Authorization", "Bearer " + _accessToken);

                    byte[] contentInBytes = Encoding.UTF8.GetBytes(notificationContent);

                    //request.Headers.Add("X-WNS-RequestForStatus", "true");

                    Stream requestStream = webRequest.GetRequestStream();
                    requestStream.Write(contentInBytes, 0, contentInBytes.Length);
                    requestStream.Close();

                    HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

                    result = (webResponse.StatusCode == HttpStatusCode.OK);

    The result is set to true, at the end.

    So, my push notification is sended? No :\

    I just use a Uri for my own computer, and wait for the Toast notification, but nothing happens.

    When i get the Web Response to Retur the WNS Debug, i find out that my conputer is conected, but the notification is dropped, but i dont even received it.

    So it could be a error with my xml code for the notification?

    Thank you

    Edit: 

    if it help, my Response Headers is Headers = {X-WNS-DEVICECONNECTIONSTATUS: connectedX-WNS-NOTIFICATIONSTATUS: droppedX-WNS-MSG-ID: 6376BF953564FDFDX-WNS-DEBUG-TRACE: DB3WNS4011535Content-Length: 0Date: Sun, 22 Apr 2012 20:25:38 GMT}
    i dont even know where i seek help or assistance
    Sunday, April 22, 2012 9:21 PM

Answers

  • I've do all these things before, none off them work for me. I check the exact same URL for Toast Capable, but it was a dead end.

    but i just solve the problem downloading the Windows Azure Toolkit for Windows 8 and creating a Metro Style app of the template "Notifications"

    I just wanna to try to see it was a problem with PC settings, but when it work, i just create a new Project and paste my code there. I dont see any diferences besides the "Internet Client & Server" e "Private Networks" capabilities on the WAT template (both also have  Internet Client capability) but i dont have any ideia if was really that and no other tutorial explain this.

    I could try desability these features to see if it still work, but i have no time for this (i just finnish my project) and i doubt that will work anyway.

    Thanks for the attention and the kindness! Have a nice day :)


    thanks

    Wednesday, April 25, 2012 11:49 AM

All replies

  • Hi Keenlanas

    Looks like your notifications are being dropped because your app has not opted in to receive toasts or you've disabled them under the user preferences.  Please verify the following:

    1) Check to ensure that your app has opted into receiving toasts. 

    You'll need to update your manifest as described in this doc here http://msdn.microsoft.com/en-us/library/windows/apps/hh781238.aspx Or in Visual Studio if you open up the Package Manifest you can enable this setting here.

    2) If that doesn't solve your problem.  Check your user level preference settings for your app.  Go to the PC Settings in Windows 8.  Under the Notifications Tab you'll see a list of apps under "Show notifications from these apps".  Make sure your app shows up here and it's turned ON.

    Hope that helps,

    Darren

    Tuesday, April 24, 2012 6:51 PM
  • I've do all these things before, none off them work for me. I check the exact same URL for Toast Capable, but it was a dead end.

    but i just solve the problem downloading the Windows Azure Toolkit for Windows 8 and creating a Metro Style app of the template "Notifications"

    I just wanna to try to see it was a problem with PC settings, but when it work, i just create a new Project and paste my code there. I dont see any diferences besides the "Internet Client & Server" e "Private Networks" capabilities on the WAT template (both also have  Internet Client capability) but i dont have any ideia if was really that and no other tutorial explain this.

    I could try desability these features to see if it still work, but i have no time for this (i just finnish my project) and i doubt that will work anyway.

    Thanks for the attention and the kindness! Have a nice day :)


    thanks

    Wednesday, April 25, 2012 11:49 AM