Search in sources :

Example 1 with SMSMessage

use of com.amazonaws.services.pinpoint.model.SMSMessage in project aws-doc-sdk-examples by awsdocs.

the class SendMessage method main.

public static void main(String[] args) throws IOException {
    try {
        Map<String, AddressConfiguration> addressMap = new HashMap<String, AddressConfiguration>();
        addressMap.put(destinationNumber, new AddressConfiguration().withChannelType(ChannelType.SMS));
        AmazonPinpoint client = AmazonPinpointClientBuilder.standard().withRegion(region).build();
        SendMessagesRequest request = new SendMessagesRequest().withApplicationId(appId).withMessageRequest(new MessageRequest().withAddresses(addressMap).withMessageConfiguration(new DirectMessageConfiguration().withSMSMessage(new SMSMessage().withBody(message).withMessageType(messageType).withOriginationNumber(originationNumber).withSenderId(senderId).withKeyword(registeredKeyword))));
        System.out.println("Sending message...");
        client.sendMessages(request);
        System.out.println("Message sent!");
    } catch (Exception ex) {
        System.out.println("The message wasn't sent. Error message: " + ex.getMessage());
    }
}
Also used : MessageRequest(com.amazonaws.services.pinpoint.model.MessageRequest) SendMessagesRequest(com.amazonaws.services.pinpoint.model.SendMessagesRequest) SMSMessage(com.amazonaws.services.pinpoint.model.SMSMessage) HashMap(java.util.HashMap) DirectMessageConfiguration(com.amazonaws.services.pinpoint.model.DirectMessageConfiguration) AmazonPinpoint(com.amazonaws.services.pinpoint.AmazonPinpoint) AddressConfiguration(com.amazonaws.services.pinpoint.model.AddressConfiguration) IOException(java.io.IOException)

Aggregations

AmazonPinpoint (com.amazonaws.services.pinpoint.AmazonPinpoint)1 AddressConfiguration (com.amazonaws.services.pinpoint.model.AddressConfiguration)1 DirectMessageConfiguration (com.amazonaws.services.pinpoint.model.DirectMessageConfiguration)1 MessageRequest (com.amazonaws.services.pinpoint.model.MessageRequest)1 SMSMessage (com.amazonaws.services.pinpoint.model.SMSMessage)1 SendMessagesRequest (com.amazonaws.services.pinpoint.model.SendMessagesRequest)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1