2012-09-15 114 views
0

我们可以从Linux服务器向Windows电话发送推送通知,还是只绑定到Windows服务器?从Linux服务器向Windows电话发送推送通知

+0

这与java有什么关系? – WeMakeSoftware

+0

如果我们可以在java中编写代码来推送windows phone,那么它可以在linux服务器上运行,并且我们可以使用java从linux服务器推送。 –

+0

您的Web服务器数据是否转到Windows Phone应用程序?你从服务器推送数据还是从WP7提取数据? – rishijasapara

回答

0

嗯,我得到了答案......

做一个HTTP POST认购URI

Java代码:

字符串toastMessage = “?< XML版本= \” 1.0 \ “encoding = \”utf-8 \“?>”+

"<wp:Notification xmlns:wp=\"WPNotification\">" + 
    "<wp:Toast>" + 
      "<wp:Text1> Welcome To Windows Push &lt;/wp:Text1>" + 
    "</wp:Toast> " + 
    "</wp:Notification>"; 


byte[] notificationMessage = toastMessage.getBytes(); 

url = new URL(subscriptionURI); //You must have the subscription URI provided by MPNS to client side. 

HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 
connection.setRequestMethod("POST"); 

connection.setDoOutput(true); 
connection.setRequestProperty("ContentLength", String.valueOf(notificationMessage.length)); 
connection.setRequestProperty("ContentType", "text/xml"); 
connection.addRequestProperty("X-WindowsPhone-Target", "toast"); 
connection.addRequestProperty("X-NotificationClass", "2"); 

connection.connect(); 

DataOutputStream out = 
    new DataOutputStream(
     connection.getOutputStream()); 
out.write(notificationMessage, 0, notificationMessage.length); 
out.close(); 
相关问题