问题
I am getting 404 error when i am working with windows phone push notifications. Any one help me out. Thanks in advance.
my code:
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;
}
I googled but i failed to rectify it. I am getting this error. The remote server returned an error: (404) Not Found.
来源:https://stackoverflow.com/questions/39699262/404-error-push-notification-in-windows-phone-rt-8-1