notnoop / java-mpns

Java Library for the Microsoft Push Notification service
BSD 3-Clause "New" or "Revised" License
37 stars 40 forks source link

MPNS bad request when push notification (WP 8.1) #12

Closed charpin closed 8 years ago

charpin commented 8 years ago

I'm currently developping an mobile application based on Cordova (version 4.0.0) for Windows Phone 8.1.

I implemented the Java code from your API to send notification to my device.

When I push the notification message to MPNS, I get this error :

HTTP/1.1 400 Bad Request [Content-Length: 0, X-WNS-MSG-ID: 50267BB8627BC17D, X-WNS-DEBUG-TRACE: DB5SCH101121935, Strict-Transport-Security: max-age=31536000; includeSubDomains, WWW-Authenticate: Bearer, Date: Thu, 07 Jan 2016 09:13:01 GMT] org.apache.http.conn.BasicManagedEntity@1ab5b13

From document of Push Notification Service response codes for Windows Phone 8, this error code means that XML document or notification URI is malformed.

Here's my notification URI :

https://db5.notify.windows.com/?token=AwYAAAC%2fHaOBh3zOgFjUbZuCSMgzXY29aQDT9wKfpkiPsd85WKBA8muqx4is4r1nBVXQOtRKqe5cc%2fxat7hq6sZBruvm6nQF7p9Sl71TIiqnGvlrdDDw6v0anax4bXUCtflPwEc%3d

Here's the XML document (generated by your API from Java class TileNotification):

<?xml version="1.0" encoding="utf-8"?>
    <wp:Notification xmlns:wp="WPNotification">
        <wp:Tile>
            <wp:Count>1</wp:Count>
            <wp:Title>Demo App Windows</wp:Title>
            <wp:BackContent>New notification</wp:BackContent>
        </wp:Tile>
    </wp:Notification>

When I compare this XML document and XML document from documentation of How to send and receive Tile notifications for Windows Phone 8, I don't see any difference or error. About my notification URI, I think the link is correct.

Do you have an idea about how to fix it ?

charpin commented 8 years ago

I made a big mistake. Here's the explanation about my problem :

I used an WNS channel URI and I tried to send notification to MPNS. But this platform expected to me to receive a MPNS channel URI. That's why from my server side, I receive from MPNS, the HTTP code 400.

Here's the channel URI associated to the specific Microsoft platform :

Microsoft recommends to use WNS platform because all of Windows Phone device where the minimum target version is 8.1 (Universal and Silverlight), use this platform.