2011-05-22 114 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";

相关问题