0

LinuxサーバーからWindowsPhoneにプッシュ通知を送信できますか、それともWindowsサーバーのみにバインドされますか?

4

1 に答える 1

0

さて私は答えを得ました...

サブスクリプションURIにhttp投稿を作成します

Javaコード:

String toastMessage = "<?xml version = \" 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();
于 2012-09-21T06:23:55.303 に答える