Windows Phone rt 8.1中的404错误推送通知

时间:2016-09-26 09:32:30

标签: c# windows-phone-8 push-notification windows-phone-8.1

当我使用Windows Phone推送通知时,我收到404错误。 任何人帮助我。提前谢谢。

我的代码:

string strChannelURI = https://hk2.notify.windows.com/?token=fgdggg/o0mhYNj9rWeJSQwvcBMGuVgDwAKXr/Q2N9C14HM7O+nVwJfZJdfG4fgvgfggfgg454545wTJg9LJ7euLWvxB0YXo7XQ4eWc=;


                    //  string PushNotificationXML1 = "<toast launch=\"/text to receive\">" + "<visual>" + " <binding template=\"ToastImageAndText02\">" + " <text id=\"1\">" + Headertext + "</text>" + " <text id=\"2\">" + Message + "</text>" + "<image id=\"1\"  src=" + imageurl + "/>" + " </binding>" + " </visual>" + "</toast>";


                    string PushNotificationXML1 = "<toast launch=\"/text to receive\">" + "<visual>" + " <binding template=\"ToastText02\">" + " <text id=\"1\">" + Headertext + "</text>" + " <text id=\"2\">" + Message + "</text>" + "</binding>" + " </visual>" + "</toast>";

                    var accessToken1 = GetAccessToken("gdrr5tyrtr//xt4t5", "ms-app://s-1-15-2-dfd454454-45455-454566sdfdgxdf-1465454545444715-2331561566-544554-454e5454545445545fffdfffffd");

                    string type = "wns/toast";
                    HttpWebRequest sendNotificationRequest = (HttpWebRequest)WebRequest.Create(strChannelURI);
                    sendNotificationRequest.Method = "POST";
                    sendNotificationRequest.Headers.Add("X-WNS-Type", type);
                    sendNotificationRequest.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken1.AccessToken));

                    byte[] notificationMessage = Encoding.Default.GetBytes(PushNotificationXML1);
                    // Set the web request content length.
                    sendNotificationRequest.ContentLength = notificationMessage.Length;
                    sendNotificationRequest.ContentType = "text/xml";
                    sendNotificationRequest.Headers.Add("X-WindowsPhone-Target", "toast");
                    sendNotificationRequest.Headers.Add("X-NotificationClass", "2");




                    using (Stream requestStream = sendNotificationRequest.GetRequestStream())
                    {
                        requestStream.Write(notificationMessage, 0, notificationMessage.Length);
                    }
                    // Send the notification and get the response.

                    HttpWebResponse response;

                    try
                    {
                        response = (HttpWebResponse)sendNotificationRequest.GetResponse();
                        string notificationStatus = response.Headers["X-NotificationStatus"];
                        string notificationChannelStatus = response.Headers["X-SubscriptionStatus"];
                        string deviceConnectionStatus = response.Headers["X-DeviceConnectionStatus"];
                    }
                    catch (WebException ex)
                    {
                        response = ex.Response as HttpWebResponse;
                    }
我用谷歌搜索但我未能纠正它。 我收到了这个错误。 远程服务器返回错误:(404)Not Found。

0 个答案:

没有答案