发送推送通知到Windows Phone 7设备?
问题描述:
因此,如果我有我自己的游戏和服务器,我怎么能从我的服务器发送推送通知到该设备,你知道应用程序读取并显示给用户在屏幕上的消息?发送推送通知到Windows Phone 7设备?
对不起,我推动通知。
答
我向您发送吐司推送通知的工作代码。
String toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1> Welcome To Windows Push </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
答
是的,你可以发送,但你为什么要发送推送通知?使用活动磁贴通知。 从Windows手机工具包使用hubtile并将Hub添加到Visual树中,并执行 hubtile1.Notification ="Something you want to send as push notification";
谢谢我检查链接现在;)我会使用Raw。 – me101 2011-05-22 16:49:29