使用示例代码推送通知时出现 404 错误

发布于 2024-11-10 02:44:15 字数 778 浏览 7 评论 0原文

我从应用程序中获取了我的网址。它的开头是:

http://sn1.notify.live.net/throttledthirdparty/01.00/

如果我使用浏览器导航到该 URL,我会收到消息:

Microsoft Push Notification Server

然后我获取了 Microsoft 提供的代码。

http://msdn.microsoft.com/en-us/library/ff402545%28v=VS.92%29.aspx

如果我采用 C# 代码,并按原样使用它(仅更改 URL,将有效负载更改为空字节数组,并将“”字符串更改为 Guid.NewGuid().ToString(),

我每次都会收到 404。

因为我没有从浏览器中收到 404,所以内容一定很重要,并且推送通知服务器依赖于内容,因此如果我通过删除通知消息并添加(按照他们的建议)将其更改为简单的原始通知:

        byte[] notificationMessage = new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
        sendNotificationRequest.Headers.Add("X-NotificationClass", "13"); 

我仍然得到一个404 每次我都尝试做 toast 通知,但结果都是一样

I got my url from the app. It begins with:

http://sn1.notify.live.net/throttledthirdparty/01.00/

and if I navigate to that URL using a browser, I get the message:

Microsoft Push Notification Server

I then grabbed the code provided by Microsoft.

http://msdn.microsoft.com/en-us/library/ff402545%28v=VS.92%29.aspx

If I take the C# code, and use it as is (changing only the URL, the Payload to be an empty byte array, and changing the "" string to Guid.NewGuid().ToString()

I get a 404 every time.

Because I don't get a 404 from by browser, the content must matter, and the push notification servers are dependent on content, so if I change it to a simple raw notification by removing the notification message and adding (as they recommend):

        byte[] notificationMessage = new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
        sendNotificationRequest.Headers.Add("X-NotificationClass", "13"); 

I still get a 404 every time. I've tried doing toast notifications with the same result.

What am I doing wrong?

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

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

发布评论

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

评论(2

北方的韩爷 2024-11-17 02:44:15

您收到 404 的原因是您发送的 notificationMessage 数据不是它所期望的。尝试一下,看看是否有效。

您可以在这里找到教程:
http://benjii. me/2011/04/push-notifications-in-windows-phone-7-3-push-that-notification/

string template =
        "<?xml version='1.0' encoding='utf-8'?>" +
        "<wp:notification xmlns:wp='WPNotification'>" +
            "<wp:toast>" +
                "<wp:text1>{0}</wp:text1>" +
                "<wp:text2>{1}</wp:text2>" +
            "</wp:toast>" +
        "</wp:notification>";

string toastXML = string.Format(template, "Testing", "This is a test");

byte[] notificationMessage = new UTF8Encoding().GetBytes(toastXML);

The reason you are getting a 404 is because the notificationMessage data you are sending isn't what it's expecting. Try this out and see if it works.

You can find a tutorial here:
http://benjii.me/2011/04/push-notifications-in-windows-phone-7-3-push-that-notification/

string template =
        "<?xml version='1.0' encoding='utf-8'?>" +
        "<wp:notification xmlns:wp='WPNotification'>" +
            "<wp:toast>" +
                "<wp:text1>{0}</wp:text1>" +
                "<wp:text2>{1}</wp:text2>" +
            "</wp:toast>" +
        "</wp:notification>";

string toastXML = string.Format(template, "Testing", "This is a test");

byte[] notificationMessage = new UTF8Encoding().GetBytes(toastXML);
梦罢 2024-11-17 02:44:15

在将 toast 通知绑定到 shell 后,我最终让我的工作正常工作。我有一个方法可以做到这一点,但在某些情况下没有调用该方法。

I ended up getting mine to work after binding toast notifications to the shell. I had a method which did it, but under some cases wasn't calling that method.

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