Aviso de fin de soporte: el 30 de octubre de 2026, AWS finalizará el soporte para Amazon Pinpoint. Después del 30 de octubre de 2026, ya no podrá acceder a la consola de Amazon Pinpoint ni a los recursos de Amazon Pinpoint (puntos de enlace, segmentos, campañas, recorridos y análisis). Para obtener más información, consulte el fin del soporte de Amazon Pinpoint. Nota: en lo APIs que respecta a los SMS, este cambio no afecta a los mensajes de voz, a las notificaciones push móviles, a las OTP y a la validación de números de teléfono, y son compatibles con la mensajería para el usuario AWS final.
Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.
GetSegments
Úselo con un AWS SDK
Los siguientes ejemplos de código muestran cómo utilizar GetSegments
.
- Java
-
- SDK para Java 2.x
-
Enumerar segmentos.
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.pinpoint.PinpointClient;
import software.amazon.awssdk.services.pinpoint.model.GetSegmentsRequest;
import software.amazon.awssdk.services.pinpoint.model.GetSegmentsResponse;
import software.amazon.awssdk.services.pinpoint.model.PinpointException;
import software.amazon.awssdk.services.pinpoint.model.SegmentResponse;
import java.util.List;
/**
* Before running this Java V2 code example, set up your development
* environment, including your credentials.
*
* For more information, see the following documentation topic:
*
* https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
*/
public class ListSegments {
public static void main(String[] args) {
final String usage = """
Usage: <appId>
Where:
appId - The ID of the application that contains a segment.
""";
if (args.length != 1) {
System.out.println(usage);
System.exit(1);
}
String appId = args[0];
PinpointClient pinpoint = PinpointClient.builder()
.region(Region.US_EAST_1)
.build();
listSegs(pinpoint, appId);
pinpoint.close();
}
public static void listSegs(PinpointClient pinpoint, String appId) {
try {
GetSegmentsRequest request = GetSegmentsRequest.builder()
.applicationId(appId)
.build();
GetSegmentsResponse response = pinpoint.getSegments(request);
List<SegmentResponse> segments = response.segmentsResponse().item();
for (SegmentResponse segment : segments) {
System.out
.println("Segement " + segment.id() + " " + segment.name() + " " + segment.lastModifiedDate());
}
} catch (PinpointException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
}
- Kotlin
-
- SDK para Kotlin
-
suspend fun listSegs(appId: String?) {
PinpointClient { region = "us-west-2" }.use { pinpoint ->
val response =
pinpoint.getSegments(
GetSegmentsRequest {
applicationId = appId
},
)
response.segmentsResponse?.item?.forEach { segment ->
println("Segement id is ${segment.id}")
}
}
}
Para ver una lista completa de guías para desarrolladores del AWS SDK y ejemplos de código, consultaUso de Amazon Pinpoint con un SDK AWS. En este tema también se incluye información sobre cómo comenzar a utilizar el SDK y detalles sobre sus versiones anteriores.