Search in sources :

Example 1 with Message

use of software.amazon.awssdk.services.pinpoint.model.Message in project aws-doc-sdk-examples by awsdocs.

the class CreateCampaign method createCampaign.

public static CampaignResponse createCampaign(PinpointClient client, String appID, String segmentID) {
    try {
        Schedule schedule = Schedule.builder().startTime("IMMEDIATE").build();
        Message defaultMessage = Message.builder().action(Action.OPEN_APP).body("My message body.").title("My message title.").build();
        MessageConfiguration messageConfiguration = MessageConfiguration.builder().defaultMessage(defaultMessage).build();
        WriteCampaignRequest request = WriteCampaignRequest.builder().description("My description").schedule(schedule).name("MyCampaign").segmentId(segmentID).messageConfiguration(messageConfiguration).build();
        CreateCampaignResponse result = client.createCampaign(CreateCampaignRequest.builder().applicationId(appID).writeCampaignRequest(request).build());
        System.out.println("Campaign ID: " + result.campaignResponse().id());
        return result.campaignResponse();
    } catch (PinpointException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
    return null;
}
Also used : MessageConfiguration(software.amazon.awssdk.services.pinpoint.model.MessageConfiguration) Message(software.amazon.awssdk.services.pinpoint.model.Message) CreateCampaignResponse(software.amazon.awssdk.services.pinpoint.model.CreateCampaignResponse) Schedule(software.amazon.awssdk.services.pinpoint.model.Schedule) PinpointException(software.amazon.awssdk.services.pinpoint.model.PinpointException) WriteCampaignRequest(software.amazon.awssdk.services.pinpoint.model.WriteCampaignRequest)

Aggregations

CreateCampaignResponse (software.amazon.awssdk.services.pinpoint.model.CreateCampaignResponse)1 Message (software.amazon.awssdk.services.pinpoint.model.Message)1 MessageConfiguration (software.amazon.awssdk.services.pinpoint.model.MessageConfiguration)1 PinpointException (software.amazon.awssdk.services.pinpoint.model.PinpointException)1 Schedule (software.amazon.awssdk.services.pinpoint.model.Schedule)1 WriteCampaignRequest (software.amazon.awssdk.services.pinpoint.model.WriteCampaignRequest)1