经过多个小时的尝试,我仍然无法向我的应用程序发送推送通知。这是我到目前为止所做的:
在
https://appdev.microsoft.com
上激活服务。获得了SID,我们称之为
ms-app://s-1-23-4-12345678901-...-12345678901
。收到了客户端秘钥,我们称之为
12Lwq7526OqNY8iN-aLkwds23451345
。在我的应用程序中,我在某个时刻实现了以下内容(简化):
PushNotificationChannel channel = null; channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); System.Diagnostics.Debug.WriteLine(channel.Uri);
这将打印出这种类型的URL:
https://db3.notify.windows.com/?token=AgY7AABrfRCVgRV%2ba4DwoDjC2omrnOVwCkdhCrrzlJi6UpIwHzcig6%2fG5xZfnDqU0%2fXoE848ddiqyTaTlSSltp2Dn9Z3qaPsMAyh7kS%2bmlis1%2bwoh%2b%2b4DsAK1yeV1d9G1rUIuFs%3s
我已经将正确的软件包名称、发布者显示名称和发布者ID添加到我的Package.appxmanifest文件中。
因此,我认为我已准备好测试推送通知。使用我自己实现的PushSharp,Fiddler的输出如下:
请求:
POST https://db3.notify.windows.com/?token=AgY7AABrfRCVgRV%2ba4DwoDjC2omrnOVwCkdhCrrzlJi6UpIwHzcig6%2fG5xZfnDqU0%2fXoE848ddiqyTaTlSSltp2Dn9Z3qaPsMAyh7kS%2bmlis1%2bwoh%2b%2b4DsAK1yeV1d9G1rUIuFs%3s HTTP/1.1 X-WNS-Type: wns/toast Authorization: Bearer EgAC4AA1hAZAQMAklDAAEgAAAUe8/AGsK8a/yk78/WEDQf+KUld/nYIvJ51OIoCPgAfwqbl0oo1sPDLhd9ChiO/iLFVzwlTPE3trp9oTkJxNXi0yUrf+FKjRciq7Utek9B/4dxH9lFNy0R5iwdMS0xNS0yLTIyNDgyMDE1NzEtMjczODcxMjkyMy0yMzM3MbsS59ZuQmXCIAFoOiAAAAAAAgzMOTB7OuFIezrhS60gEAAoANS45LjYuMTBiPoPMh3Nj5MAEOp0RhrcMUx6D50AtDuzWE1AAAAAABeAG1zLWiwcDovL3MtTk2Nzk3LTEzOTYwNDkxODYtMjEyODYwMTQ3MS04MDg1MDg2ODUtMzY3NjQyNTk3OQA= Content-Type: text/xml Host: db3.notify.windows.com Content-Length: 138 <toast> <visual> <binding template="ToastText01"> <text id="1">This is a test</text> </binding> </visual> </toast>
答案
HTTP/1.1 403 Forbidden Content-Length: 0 X-WNS-ERROR-DESCRIPTION: Channel URL incompatible with caller app X-WNS-MSG-ID: 5FC550364E079585 X-WNS-DEBUG-TRACE: DB3WNS4011533 Date: Mon, 23 Dec 2013 23:58:22 GMT
我迄今为止找到的 Channel URL incompatible with caller app 这篇文章并没有真正帮到我
我使用 http://31daysofwindows8.com/push 的网络服务时也遇到了相同的错误。我该怎么办?可能出了什么问题?请注意,该应用程序尚未发布到商店,我正在本地的 Windows 8.1 安装上进行测试。