【问题标题】:AWS SNS Endpoint not sending sms after 9 pm ISTAWS SNS 终端节点在 IST 晚上 9 点之后不发送短信
【发布时间】:2019-12-24 10:25:50
【问题描述】:

我正在使用 AWS SDK 将短信发送到手机号码,以便通过短信发送 OTP。

我面临的问题是 SMS 仅根据印度标准时间(上午 9 点至晚上 9 点)在白天发送。如果我在晚上 9 点之后尝试向 AWS SNS 端点发送 SMS 请求,那么它将在第二天早上 9 点之后发送消息。

代码如下。

String ACCESS_KEY = env.getProperty("aws.access.key");
String SECRET_KEY = env.getProperty("aws.secret.access.key");

// Above we get the access and secret access key as credentials for the user.

String otp = getRandomNumberString();  // generates an OTP number of 4 digit

AmazonSNSClient snsClient = new AmazonSNSClient(new BasicAWSCredentials(ACCESS_KEY, 
         SECRET_KEY));

String message = "Your Connect OTP for Login/Signup is: " + otp
    + ".\nNote: Please DO NOT SHARE THIS OTP with anyone.\nThanks";
String phoneNumber = "+91" + String.valueOf(mobile); // Ex: +91XXX4374XX
String messageID = sendSMSMessage(snsClient, message, phoneNumber);

// The definition of method named "sendSMSMessage" as above is written below in next code block
//definition of method named "sendSMSMessage"

public static String sendSMSMessage(AmazonSNSClient snsClient, String message, String phoneNumber) {
    PublishResult result = snsClient
        .publish(new PublishRequest().withMessage(message).withPhoneNumber(phoneNumber));
    return result.getMessageId();
}

【问题讨论】:

标签: amazon-web-services amazon-sns aws-java-sdk


【解决方案1】:

您可以发送两种类型的短信。

-促销信息
-交易信息

促销信息就像广告。根据 NCPR 指南,这些消息不会传递给免打扰号码,而且这些消息只能在上午 9 点到晚上 9 点之间传递。

交易消息 发送用于交易目的,例如发送 OTP 和发送付款确认。这些消息可以 24/7 全天候发送到任何号码。

所以问题是您需要将短信类型更改为交易短信

【讨论】:

    猜你喜欢
    • 2021-04-06
    • 2018-11-30
    • 2016-06-27
    • 1970-01-01
    • 1970-01-01
    • 2016-01-18
    • 1970-01-01
    • 2017-11-01
    • 1970-01-01
    相关资源
    最近更新 更多