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



我是一个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
{}

最新更新