Skip to content

Instantly share code, notes, and snippets.

Created September 7, 2016 02:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save steveperkins/85dbcc909d462ca3dd18bd33e3d39de1 to your computer and use it in GitHub Desktop.
package org.lightside.notification;
import java.util.HashMap;
import java.util.Map;
import org.lightside.main.AwsClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SmsNotificationService {
private static final Logger LOG = LoggerFactory.getLogger(SmsNotificationService.class);
public PublishResult send(String phoneNumber, String message) {
Map<String, MessageAttributeValue> smsAttributes = new HashMap<String, MessageAttributeValue>();
smsAttributes.put("AWS.SNS.SMS.SenderID", new MessageAttributeValue()
.withStringValue("Lightside") //The sender ID shown on the device (except in US)
smsAttributes.put("AWS.SNS.SMS.MaxPrice", new MessageAttributeValue()
.withStringValue("0.01") //Sets the max price to 0.01 USD.
smsAttributes.put("AWS.SNS.SMS.SMSType", new MessageAttributeValue()
.withStringValue("Promotional") //Sets the type to promotional.
PublishResult result = AwsClientFactory.getSnsClient().publish(new PublishRequest()
.withMessageAttributes(smsAttributes));"Sent SMS message ID: " + result.getMessageId());
return result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment