We are using Amazon SNS for our push notification service. It used to work fine, until I've thought to include a TTL - in MessageAttributes. Basically For testing purpose I want to keep the TTL Time as 60 seconds.
I use RestClient. I donot use Amazon SDK.
def publish(endpoint_arn, message,message_attribute)
params = {
:TargetArn => endpoint_arn,
:Message => JSON.dump(message),
:MessageStructure => 'json',
:MessageAttributes => {
message_attribute => {
:DataType => 'String',
:StringValue => '60'
}
}
}
post(:Publish, params)
end
message_attribute is a string that contains, 'AWS.SNS.MOBILE.GCM.TTL'
def post(command, params)
params.merge!(default_post_params(command))
params[:Signature] = calculate_signature(params, 'POST')
response = RestClient.post(SNS_URL, params)
end
Whats wrong in the code above, Amazon document says what i've done is correct.
Amazon SDK API Reference: http://docs.aws.amazon.com/sns/latest/dg/sns-ttl.html
PS: default_post_params, would have a generalised post params, like Access Key, SNS Url. And it works fine. Only after including MessageAttributes key it says,
<Error>
<Type>Sender</Type>
<Code>MalformedQueryString</Code>
<Message>Keys may not contain [</Message>
</Error>