在 lambda 中通过 SNS 发送短信时未收到短信

发布于 2025-01-18 08:59:07 字数 1318 浏览 3 评论 0原文

当在lambda函数中,我的代码是此的

  const otp = generateOTP();
  const message = `Your XXXX Verification Code is ${otp} .`;
  var params = {
    Message: message,
    PhoneNumber: "+91xxxxxxxxxx",
  };

  AWS.config.update({region: 'ap-south-1'});

  var publishTextPromise = new AWS.SNS({apiVersion: '2022-04-01'}).publish(params).promise();

  return new Promise((resolve, reject) => {
      publishTextPromise.then((data) => {
          console.log("MessageID is " + data.MessageId);
          const response = {
              statusCode: 200,
              headers: {
                  "Content-Type": "application/json"
              },
              body: JSON.stringify(data)
          };
          console.log('Server response function');
          resolve(response);
      }).catch((error) => { reject(Error(error)); });
  });

在调用此lambda功能时会得到此响应

Server response function
{
    "statusCode": 200,
    "headers": {
        "Content-Type": "application/json"
    },
    "body": {
        "ResponseMetadata": {
            "RequestId": "29796d67-f32e-5e42-a761-37a72809164d"
        },
        "MessageId": "2f8ffee0-7e0d-5cd3-a5b0-a420a52a14dc"
    }
}

,我 我将在控制台中得到解决的响应,这意味着SMS已发送,但我没有收到它。 我必须在AWS SNS Mobile中配置SNS手册吗?文字消息或其他? 还是他们发送验证OTP的其他方法?

I am sending the OTP using AWS SNS service when in a lambda function my code is this

  const otp = generateOTP();
  const message = `Your XXXX Verification Code is ${otp} .`;
  var params = {
    Message: message,
    PhoneNumber: "+91xxxxxxxxxx",
  };

  AWS.config.update({region: 'ap-south-1'});

  var publishTextPromise = new AWS.SNS({apiVersion: '2022-04-01'}).publish(params).promise();

  return new Promise((resolve, reject) => {
      publishTextPromise.then((data) => {
          console.log("MessageID is " + data.MessageId);
          const response = {
              statusCode: 200,
              headers: {
                  "Content-Type": "application/json"
              },
              body: JSON.stringify(data)
          };
          console.log('Server response function');
          resolve(response);
      }).catch((error) => { reject(Error(error)); });
  });

and i am getting this response when invoking this lambda function

Server response function
{
    "statusCode": 200,
    "headers": {
        "Content-Type": "application/json"
    },
    "body": {
        "ResponseMetadata": {
            "RequestId": "29796d67-f32e-5e42-a761-37a72809164d"
        },
        "MessageId": "2f8ffee0-7e0d-5cd3-a5b0-a420a52a14dc"
    }
}

But I am not receiving the SMS on that number I don't know what is the problem here cause the I am getting resolved response in the console which means the SMS is send but I am not received it.
Do I have to config the sns manual in aws sns mobile -> text messaging or something??
or is their any other way to send verification otp ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文