2011-05-22 126 views
0

因此,如果我有我自己的遊戲和服務器,我怎麼能從我的服務器發送推送通知到該設備,你知道應用程序讀取並顯示給用戶在屏幕上的消息?發送推送通知到Windows Phone 7設備?

對不起,我推動通知。

回答

2

你從哪裏開始看?

的Windows Phone 7支持幾個不同的通知,如麪包,活的瓷磚,原材料等

我建議你開始here和閱讀更多關於他們的一點,按照鏈接到相應的文件和例子。

+0

謝謝我檢查鏈接現在;)我會使用Raw。 – me101 2011-05-22 16:49:29

1

我向您發送吐司推送通知的工作代碼。

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(); 
+0

我們可以從應用程序發送推送通知給自己嗎? – 2013-04-26 06:57:13

0

是的,你可以發送,但你爲什麼要發送推送通知?使用活動磁貼通知。 從Windows手機工具包使用hubtile並將Hub添加到Visual樹中,並執行 hubtile1.Notification ="Something you want to send as push notification";

相關問題