I am attempting to send a raw notification to WNS by setting message attributes, but it appears that a toast notification is being sent instead.
Here is the C# code I'm using to build the publish request.
var request = new PublishRequest()
{
TopicArn = TOPIC_ARN,
Message = "Test Message",
MessageAttributes = new Dictionary<string, MessageAttributeValue>()
{
{ "AWS.SNS.MOBILE.WNS.Type", new MessageAttributeValue() { StringValue = "wns/raw", DataType = "String" } }
}
};
From what I can tell, I am setting the X-WNS-Type correctly using SNS Message Attributes, but the notification is still received as a toast on the client. Are there any examples of somebody doing this successfully?
I was able to get it working by using MessageStructure
. Setting the value to json
and updating Message
to have a message specifically for WNS did the trick. My assumption is that the WNS value for MessageAttributes
only applies if a message is defined specifically for WNS.
var request = new PublishRequest()
{
TopicArn = TOPIC_ARN,
Message = "{ \"default\": \"default message\", \"WNS\" : \"raw message\"}",
MessageAttributes = new Dictionary<string, MessageAttributeValue>()
{
{ "AWS.SNS.MOBILE.WNS.Type", new MessageAttributeValue() { StringValue = "wns/raw", DataType = "String" } }
},
MessageStructure = "json",
};