2013-03-21 76 views

回答

2

要發送推你必須有ChannelURI其他手機。有一個關於它 http://msdn.microsoft.com/en-us/library/hh221549.aspx

好文章。當你有這樣的ADRESS你必須發送特殊的XML數據

 string textTitle = tbxTitle.Text; 
     string textSubtitle = tbxSubtitle.Text; 

     string deviceUri = tbxUri.Text; 

     string msg = 
      "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + 
      "<wp:Notification xmlns:wp=\"WPNotification\">" + 
       "<wp:Toast>" + 
       "<wp:Text1>" + textTitle + "</wp:Text1>" + 
       "<wp:Text2>" + textSubtitle + "</wp:Text2>" + 
       "</wp:Toast>" + 
      "</wp:Notification>"; 

     byte[] msgBytes = new UTF8Encoding().GetBytes(msg); 

     HttpWebRequest request = (HttpWebRequest)WebRequest.Create(channelUri); 
     request.Method = WebRequestMethods.Http.Post; 
     request.ContentType = "text/xml"; 
     request.ContentLength = msg.Length; 
     request.Headers["X-MessageID"] = Guid.NewGuid().ToString(); 
     request.Headers["X-WindowsPhone-Target"] = "toast"; 
     request.Headers["X-NotificationClass"] = "2"; 

     Stream requestStream = request.GetRequestStream(); 
     requestStream.Write(msgBytes, 0, msgBytes.Length); 
     requestStream.Close(); 
+0

所以,我需要知道,這兩個URI地址? – JuP 2013-03-21 15:24:22

+0

不,你必須知道只有收件人的地址。每部電話都必須有第二個電話地址 – Jacek 2013-03-21 15:25:01