2014-01-29 66 views
0

我是一名android开发人员,并多次实施推送通知。现在,我尝试了相同的Windows手机。作为初学者,我无法完成任务。使用Azure在Windows Phone 8中推送通知

我都遵循类似的多个链接:

Link 1 Link 2 Link 3

我有我自己的应用程序,并且希望自己的服务器来发送使用Azure服务的推送通知。

请帮忙。

+0

如果你按照link1你应该没问题。在哪个步骤中,您对指南有问题? –

回答

0

我用下面的代码发送推送通知到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 
{} 
相关问题