基于Creating the Remote Notification Payload,可以将App特定数据发送到SNS,例如,
{
"aps" : { "alert" : "Message received from Bob" },
"acme2" : [ "bang", "whiz" ]
}
如何使用AmazonSNS在Java中设置数据
final PublishRequest publishRequest = new PublishRequest();
publishRequest
.withTargetArn(getDeviceEndpoint())
.withMessage(notification.getMessage())
.withSubject(notification.getTitle());
return snsClient.publish(publishRequest).getMessageId();
最佳答案
原来我需要将消息类型设置为json
publishRequest
.withTargetArn(userByUsername.get().getDeviceEndpoint())
.withMessage("{... json here ... }")
.withSubject(enclosedNotificiation.getTitle())
.withMessageStructure("json")