向 Windows Phone 7 设备发送推送通知?

发布于 2024-11-08 15:56:26 字数 93 浏览 0 评论 0原文

因此,如果我有自己的游戏和服务器,我如何从我的服务器向该设备发送推送通知,就像应用程序读取并在屏幕上向用户显示的消息一样?

抱歉,在推送通知方面我是个菜鸟。

So if I have my own game and server, how can I send push notifications to that device from my server, you know like a message that the application reads and display it to the user on the screen?

Sorry Im a noob when it comes to push notifications.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

耳钉梦 2024-11-15 15:56:26

你从哪里开始寻找?

Windows Phone 7 支持几种不同的通知,例如 Toast、Live Tiles、Raw 等。

我建议从 此处 并进一步阅读有关它们的内容,然后单击链接到相应的文档和示例。

Where have you started looking?

Windows Phone 7 supports a few different notifications, such as Toast, Live Tiles, Raw, etc.

I'd recommend starting here and reading about them a bit more, and follow the links to the appropriate documentation and examples.

暮光沉寂 2024-11-15 15:56:26

我正在向您发送 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();

I am sending you the working code for toast push notification.

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();
空宴 2024-11-15 15:56:26

是的,您可以发送,但为什么要发送推送通知?为此使用动态磁贴通知。
使用 Windows Phone 工具包中的 hubtile 并将 Hub 添加到可视化树中,然后执行
hubtile1.Notification ="您想要作为推送通知发送的内容";

Yes you can send, but why should you send a push notification ? use live tile notification for that.
use hubtile from Windows phone toolkit and add the Hub to the Visual tree, and do
hubtile1.Notification ="Something you want to send as push notification";

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文