2012-09-15 6 views
0

Linux 서버에서 Windows 전화로 푸시 알림을 보내거나 Windows 서버에만 바인딩 할 수 있습니까?Linux 서버에서 Windows 전화로 푸시 알림 보내기

+0

이것은 java와 어떤 관련이 있습니까? – WeMakeSoftware

+0

자바에서 코드를 작성하여 윈도우 폰에 푸시 할 수 있다면 리눅스 서버에서 실행할 수 있고 우리는 자바를 사용하여 리눅스 서버에서 푸시를 할 수있다. –

+0

웹 서버의 데이터가 Windows Phone 앱으로 이동합니까? 서버에서 데이터를 가져 오거나 WP7에서 데이터를 가져 옵니까? – rishijasapara

답변

0

그럼 난 대답 ...

이 구독 URI

자바 코드에 HTTP 게시합니다 가지고 :

문자열 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(); 
관련 문제