因此,如果我有自己的游戏和服务器,我如何从我的服务器向该设备发送推送通知,您知道应用程序读取消息并将其显示在屏幕上吗?
抱歉,在推送通知方面,我是个菜鸟。
因此,如果我有自己的游戏和服务器,我如何从我的服务器向该设备发送推送通知,您知道应用程序读取消息并将其显示在屏幕上吗?
抱歉,在推送通知方面,我是个菜鸟。
我正在向您发送 toast 推送通知的工作代码。
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();
是的,您可以发送,但为什么要发送推送通知?为此使用动态磁贴通知。使用 Windows phone 工具包中的 hubtile 并将 Hub 添加到 Visual 树,然后执行
hubtile1.Notification ="Something you want to send as push notification";