因此,如果我拥有自己的游戏和服务器,如何从服务器向该设备发送推送通知,您知道应用程序读取的消息并将其显示给屏幕上的用户?
对不起我是一个推送通知的菜鸟。
答案 0 :(得分:2)
答案 1 :(得分:1)
我正在向您发送吐司推送通知的工作代码。
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();
答案 2 :(得分:0)
是的,您可以发送,但为什么要发送推送通知?使用实时图块通知。
使用Windows Phone工具包中的hubtile并将Hub添加到Visual树中,然后执行
hubtile1.Notification ="Something you want to send as push notification";