4

I'm writing code to send an OTP message. My current parameters and publish method look as follows:

params = {
  Message: otpMessage,
  MessageStructure: 'string',
  PhoneNumber: contactNo
};

sns.publish(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else console.log(data);           // successful response
});

How do I set the TTL attribute?

muds
  • 518
  • 1
  • 3
  • 13

2 Answers2

0

It appears you would like to set TTL attribute when sending OTP messages but currently Amazon SNS does not support setting TTL for any of the following :

  • SMS
  • SQS
  • HTTP
  • email.

TTL is only applicable when sending mobile push notification using any of the following platform :

  • APNS
  • APNS_Sandbox

  • FCM

  • ADM

  • Baidu

  • WNS

aksyuma
  • 2,957
  • 1
  • 15
  • 29
0

I set it up like this:

const params = {
    MessageStructure: 'json',
    Message: message,
    MessageAttributes: {
      'AWS.SNS.MOBILE.APNS.TTL': { DataType: 'Number', StringValue: '3600' },
      'AWS.SNS.MOBILE.FCM.TTL': { DataType: 'Number', StringValue: '3600' },
    },          
    TopicArn: topicArn
}
Yanov
  • 655
  • 7
  • 13