我有:
{ "GCM":"{“数据”:{ "MyTitle":“示例端点”,"MyMessage":“重要”}
"{MyTitle=Sample端点,MyMessage=Important}“
{default={"GCM":"{“数据”:{"MyTitle":“示例端点”,"MyMessgae“:"Criticald”}
发布于 2022-10-06 23:52:54
从AWS控制台发送消息与使用AmazonSimpleNotificationServiceClient发送消息不同。
您需要构造"PublishRequest“对象。
这是一个工作代码:
// 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);
}示例消息:在这里输入图像描述
https://stackoverflow.com/questions/73704905
复制相似问题