[英]Push notification in Windows phone 8 using Azure
我使用以下代碼將推送通知發送到Windows 8移動應用程序。 語言是C#asp.net。
var sendNotificationRequest = (HttpWebRequest)WebRequest.Create(Notification URL);
sendNotificationRequest.Method = "POST";
const string tileMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Tile>" +
"<wp:BackgroundImage>" + "</wp:BackgroundImage>" +
"<wp:Count>" + "1" + "</wp:Count>" +
"<wp:Title>" + "Completed" + "</wp:Title>" +
"<wp:BackBackgroundImage>" + "</wp:BackBackgroundImage>" +
"<wp:BackTitle>" + "</wp:BackTitle>" +
"<wp:BackContent>" + "</wp:BackContent>" +
"</wp:Tile> " +
"</wp:Notification>";
byte[] notificationMessage = Encoding.Default.GetBytes(tileMessage);
sendNotificationRequest.ContentLength = notificationMessage.Length;
sendNotificationRequest.ContentType = "text/xml";
sendNotificationRequest.Headers.Add("X-WindowsPhone-Target", "token");
sendNotificationRequest.Headers.Add("X-NotificationClass", "1");
try
{
using (Stream requestStream = sendNotificationRequest.GetRequestStream())
{
requestStream.Write(notificationMessage, 0, notificationMessage.Length);
}
var response = (HttpWebResponse)sendNotificationRequest.GetResponse();
string notificationStatus = response.Headers["X-NotificationStatus"];
string notificationChannelStatus = response.Headers["X-SubscriptionStatus"];
string deviceConnectionStatus = response.Headers["X-DeviceConnectionStatus"];
}
catch
{}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.