【问题标题】:How to set the TTL attribute in the publish method of SNS in NodeJS?NodeJS中如何在SNS的发布方法中设置TTL属性?
【发布时间】:2022-01-19 17:21:47
【问题描述】:

我正在编写代码来发送 OTP 消息。我当前的参数和发布方法如下所示:

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
});

如何设置 TTL 属性?

【问题讨论】:

    标签: node.js amazon-web-services amazon-sns ttl


    【解决方案1】:

    您似乎想在发送 OTP 消息时设置 TTL 属性,但目前 Amazon SNS 不支持为以下任何 设置 TTL:

    • 短信
    • SQS
    • HTTP
    • 电子邮件

    TTL 仅在使用以下任一平台发送移动推送通知时适用

    • APNS
    • APNS_Sandbox

    • FCM

    • ADM

    • 百度

    • WNS

    【讨论】:

      【解决方案2】:

      我是这样设置的:

      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
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-11-17
        • 1970-01-01
        • 2011-07-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-06
        相关资源
        最近更新 更多