I have:
{ "GCM": "{ "data": { "MyTitle": "Sample endpoints", "MyMessage": "Important" } }" }
Amazon SNS Console - Publish Message
"{MyTitle=Sample endpoints, MyMessage=Important}"
Android Studio - Message received
Visual studio .NET Application
{default={"GCM": "{ "data": {"MyTitle": "Sample endpoints", "MyMessgae" : "Criticald" } } " }}
Android Studio - Message received
Sending the message from the AWS Console is different from sending the message using AmazonSimpleNotificationServiceClient.
You will need to construct "PublishRequest" object.
This is a working code:
// Android Payload
string payload = "\\\"data\\\":{\\\"MyTitle\\\":\\\"test message \\\", \\\"MyMessage\\\": \\\"Important\\\"}";
// iOS Payload
//string payload = "\\\"notification\\\" : {\\\"content_available\\\" : true }, \\\"data\\\": { \\\"MyTitle\\\": \\\"Sample message for iOS endpoints\\\", \\\"MyMessage\\\":\\\"Hello world\\\",\\\"Payload\\\": {\\\"InstructionID\\\": \\\"f7a87860-11f4-47e1-8a39-3da2ffd6eadb\\\",\\\"IsAlert\\\": false,\\\"Content\\\": \\\"This is new content\\\",\\\"Value\\\": 2.554,\\\"Counter\\\": 290,\\\"DateTime\\\": \\\"2022-09-11T16:13:57.2009482Z\\\"}}";
var request = new PublishRequest
{
Message = "{\"default\": \"default message\",\"GCM\":\"{" + payload + "}\"}",
TargetArn = fcmARN,
MessageStructure = "json"
};
try
{
var response = await snsClient.PublishAsync(request);
if (response.HttpStatusCode.Equals(HttpStatusCode.OK))
Console.WriteLine("Message Sent to Topic");
else
Console.WriteLine("Failed - Message Sent to Topic");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Example Message: enter image description here