A user will create an account on my web app. The app will need to authenticate the user by sending a text message to the mobile phone number that the user provides. The text m
Sending an SMS using the AWS SDK for Java:
public static void main(String[] args) {
AmazonSNSClient snsClient = new AmazonSNSClient();
String message = "My SMS message";
String phoneNumber = "+1XXX5550100";
Map smsAttributes =
new HashMap();
//
sendSMSMessage(snsClient, message, phoneNumber, smsAttributes);
}
public static void sendSMSMessage(AmazonSNSClient snsClient, String message,
String phoneNumber, Map smsAttributes) {
PublishResult result = snsClient.publish(new PublishRequest()
.withMessage(message)
.withPhoneNumber(phoneNumber)
.withMessageAttributes(smsAttributes));
System.out.println(result); // Prints the message ID.
}
For this particular use case you should consider the AWS Customer Engagement Service Amazon Pinpoint. It allows sending SMS, emails and push notifications, with tools for marketing campaigns as well as analytics:
Amazon Pinpoint Developer Guide
The documentation includes a tutorial for your specific use case:
Setting Up an SMS Registration System Using Amazon Pinpoint
For what you described, while it could be done using SNS with the AWS SDK for Java, Pinpoint is designed to interact with application users, so it's probably a better alternative