簡體   English   中英

使用Azure在Windows Phone 8中推送通知

[英]Push notification in Windows phone 8 using Azure

我是一名Android開發人員,已經多次實施了推送通知。 現在,我為Windows Phone嘗試了同樣的方法。 作為初學者,我無法完成任務。

我已經跟隨多個鏈接,如:

鏈接1 鏈接2 鏈接3

我有自己的應用程序,並希望我自己的服務器使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM