0

Can we send a push notification to a windows phone from a linux server or is this bound to a windows server only?

4

1 回答 1

0

嗯,我得到了答案...

向订阅 URI 发布 http 帖子

Java 代码:

String toastMessage = "<?xml 版本=\"1.0\" 编码=\"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();
于 2012-09-21T06:23:55.303 回答