[Enhancement]: Send bulk push notifications
Background story
I need to use pinpoint for sending push notifications in batches, instead of 1:1. The public documentation provides example (https://docs.aws.amazon.com/pinpoint/latest/developerguide/send-messages-sms.html) of using the SendMessages API to send a single SMS message. I can tweak it to send a single push notification but I am wondering how to tweak it further to send multiple push notifications at once.
The API documentation (https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html) also mentions that You can send a direct message to as many as 100 recipients. , but there is no example of how to do this. A code example in java would really help!
What does this example accomplish?
Java code to use AWS pinpoint SDK to send push notifications to X different customers at once.
Which AWS service(s)?
Pinpoint
Which AWS SDKs or tools?
- [ ] All languages
- [ ] .NET
- [ ] Go (v2)
- [ ] Java
- [X] Java (v2)
- [ ] JavaScript
- [ ] JavaScript (v3)
- [ ] Kotlin
- [ ] PHP
- [ ] Python
- [ ] Ruby
- [ ] Rust
- [ ] Swift
- [ ] Not applicable
Are there existing code examples to leverage?
Code reference to send a single message:
` public static void sendSMSMessage(PinpointClient pinpoint, String message, String appId, String originationNumber, String destinationNumber) {
try {
Map<String, AddressConfiguration> addressMap =
new HashMap<String, AddressConfiguration>();
AddressConfiguration addConfig = AddressConfiguration.builder()
.channelType(ChannelType.SMS)
.build();
addressMap.put(destinationNumber, addConfig);
SMSMessage smsMessage = SMSMessage.builder()
.body(message)
.messageType(messageType)
.originationNumber(originationNumber)
.senderId(senderId)
.keyword(registeredKeyword)
.build();
// Create a DirectMessageConfiguration object
DirectMessageConfiguration direct = DirectMessageConfiguration.builder()
.smsMessage(smsMessage)
.build();
MessageRequest msgReq = MessageRequest.builder()
.addresses(addressMap)
.messageConfiguration(direct)
.build();
// create a SendMessagesRequest object
SendMessagesRequest request = SendMessagesRequest.builder()
.applicationId(appId)
.messageRequest(msgReq)
.build();
SendMessagesResponse response= pinpoint.sendMessages(request);
MessageResponse msg1 = response.messageResponse();
Map map1 = msg1.result();
//Write out the result of sendMessage
map1.forEach((k, v) -> System.out.println((k + ":" + v)));
} catch (PinpointException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}`
Do you have any reference code?
No response