Azure/azure-notificationhubs-java-backend

Can't send UWP notification when toast tag with parameters

rustem08 opened this issue · 5 comments

Hello.
When I try to send UWP notification like
<toast launch="test_launch">
I get
Error: HTTP/1.1 400 Bad Request body: <Error><Code>400</Code><Detail>The mandatory HTTP header 'X-WNS-Type' is missing.TrackingId:c973b157-3a55-4e2a-b0bf-2805eaac8d22_G0,

I think there is issue in createWindowsNotification method at Notification.java at code

if (body.contains("<toast>"))

Yeah, Even after adding the X-WNS-Type header as wns/toast, the notification is not received by the UWP application.

Thanks for filing this, @rustem08! Looks like a good bug.

@Druffl3, I believe your issue is an independent one. If you can pare down your situation to a specific SDK related problem, please file a new issue. Otherwise, take a look at our other support options: https://azure.microsoft.com/en-us/support/options/#overview

To work around this bug until we're able to publish a fix, folks can add the header themselves manually in the following way:

Notification myNotification = Notifiation.createWindowsNotification("<toast launch=\"test_launch\">/* my toast body */</toast>");
Map<String, String> myNotificationHeaders = myNotification.getHeaders();
myNotificationHeaders.put("X-WNS-Type", "wns/toast");
myNotification.setHeaders(myNotificationHeaders);

Yes, and that is what fixed for us as well. I had already raised an issue here: MicrosoftDocs/azure-docs#58779

Next time we release (can't promise timeline right at the moment) this will be fixed for you.