我正在通过WNS和WINJS(Windows Phone 8.1)研究推送通知。我遵循了这篇文章https://msdn.microsoft.com/en-us/library/windows/apps/hh465460.aspx。目前,我无法在我的设备上接收推送通知,但是WNS服务器以状态码200和已接收消息回答了我。
HTTP/1.1 200 OK
Content-Length: 0
X-WNS-DEVICECONNECTIONSTATUS: connected
X-WNS-NOTIFICATIONSTATUS: received
X-WNS-STATUS: received
X-WNS-MSG-ID: 77B3599101A23AB8
X-WNS-DEBUG-TRACE: DB3WNS2010831
Strict-Transport-Security: max-age=31536000; includeSubDomains
Date: Wed, 18 Mar 2015 13:58:29 GMT
我的请求头(在PHP中循环)是:
[0] => Content-Type: text/xml
[1] => Content-Length: 142
[2] => X-WNS-TTL: 3600000
[3] => X-WNS-Type: wns/toast
[4] => X-WNS-RequestForStatus: true
[5] => Authorization: Bearer EgAeAQMAAAAEgAAAC4AA90q2GTPfvxMbeV....
我的xml测试有效负载是:
<toast>
<visual lang="it-IT">
<binding template="ToastText02">
<text id="1">Hello</text>
</binding>
</visual>
</toast>
显然,对于服务器来说,我的请求是正常的,但是没有任何东西发送到设备(无论是关闭应用程序还是运行应用程序与关联的pushnotificationreceived事件)。我还检查了这个列表https://msdn.microsoft.com/en-us/library/windows/apps/dn457490.aspx#push_200_OK,但是没有成功,似乎(对我来说)一切都设置得很好。我真的对此感到非常生气,我不知道错误到底在哪里。 有人遇到过同样的问题吗?非常感谢
#<Net::HTTPMethodNotAllowed 405 Method Not Allowed readbody=true>
错误。@user3149172.. 我尝试了你的解决方案,但也没有帮助。 这是我的请求代码片段 -request = Net :: HTTP :: Post.new(uri.path,{"Authorization" => "#{windows_access_token}", "Content-Type" => "text/xml", 'Content-Length' => '0', 'X-WNS-Type' => 'wns/toast' })
- Neha