6
votes

I'm working on push notifications through WNS and WINJS (windows Phone 8.1). I followed this article https://msdn.microsoft.com/en-us/library/windows/apps/hh465460.aspx. Right now i can't receive push notifications on my devices, but the WNS servers answer me with status 200 and message received

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

My request's header (looped in php) is:

[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....

My xml test payload is:

<toast>
  <visual lang="it-IT">
    <binding template="ToastText02">
       <text id="1">Hello</text>
    </binding>
  </visual>
</toast>

So apparently for the server, my request is fine, but nothing is sent to the device (neither with closed app or running app with associated pushnotificationreceived event). I also checked this list https://msdn.microsoft.com/en-us/library/windows/apps/dn457490.aspx#push_200_OK , but with no success, it seems (to me) that everything is set fine. I'm literally getting mad at this , I don't know where the error really is. Anyone had the same problem? thanks a lot

2
Facing the same problem! I have cross checked all headers and my request payload and it just won't work! On the REST console, it gives me a 200 OK status. When i try doing the same with the Ruby code, it throws #<Net::HTTPMethodNotAllowed 405 Method Not Allowed readbody=true> error. @user3149172.. tried your solution but its not helping either. This is my code snippet for the request - request = Net::HTTP::Post.new(uri.path, {"Authorization" => "#{windows_access_token}", "Content-Type" => "text/xml", 'Content-Length' => '0', 'X-WNS-Type' => 'wns/toast' })Neha

2 Answers

1
votes

I had the exact issue, after spending several hours reading and trying numerous things I finally found the problem. The package manifest for the WP8.1 app has an option for enabling toast notifications, under Application tab; you need to explicitly set "Yes".

Man, that was frustrating as there was no indication of what was failing!

0
votes

I had also many problems with push notifications.

  1. I understand that you have associated App with Store ?
  2. Uninstall your app and obtain new URI of device.
  3. Send only "Authorization" and "X-WNS-Type" headers.
  4. My working example <?xml version=\"1.0\" encoding=\"utf-16\"?><toast><visual><binding template=\"ToastImageAndText01\"><image id=\"1\" src=\"\"/><text id=\"1\"></text></binding></visual></toast>