Amazon Pinpoint를 사용하여 프로그래밍 방식으로 엔드포인트에 대한 인앱 메시지 검색 - Amazon Pinpoint

지원 종료 공지: 2026년 10월 30일에 Amazon Pinpoint에 대한 지원이 AWS 종료됩니다. 2026년 10월 30일 이후에는 Amazon Pinpoint 콘솔 또는 Amazon Pinpoint 리소스(엔드포인트, 세그먼트, 캠페인, 여정, 분석)에 더 이상 액세스할 수 없습니다. 자세한 내용은 Amazon Pinpoint 지원 종료를 참조하세요. 참고: SMS, 음성, 모바일 푸시, OTP 및 전화번호 검증과 관련된 APIs는이 변경의 영향을 받지 않으며 AWS 최종 사용자 메시징에서 지원됩니다.

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

Amazon Pinpoint를 사용하여 프로그래밍 방식으로 엔드포인트에 대한 인앱 메시지 검색

애플리케이션은 GetInAppMessages API를 직접적으로 호출하여 주어진 엔드포인트에 권한이 부여된 모든 인앱 메시지를 검색할 수 있습니다. GetInAppMessages API를 직접적으로 호출할 경우 다음과 같은 파라미터를 제공하게 됩니다.

  • ApplicationId - 인앱 메시지 캠페인이 연결된 Amazon Pinpoint 앱의 고유 ID입니다.

  • EndpointId - 메시지를 검색할 엔드포인트의 고유 ID입니다.

이러한 값을 사용하여 API를 직접적으로 호출하면 메시지 목록이 반환됩니다. 이 작업으로 생성된 응답에 대한 자세한 내용은 GetInAppMessages Amazon Pinpoint API 응답 JSON 예제 섹션을 참조하세요.

AWS SDKs를 사용하여 GetInAppMessages 작업을 호출할 수 있습니다. 다음 코드 예제에는 인앱 메시지를 검색하는 함수가 포함되어 있습니다.

JavaScript

별도의 모듈에서 클라이언트를 생성하고 내보냅니다.

import { PinpointClient } from "@aws-sdk/client-pinpoint"; const REGION = "us-east-1"; const pinClient = new PinpointClient({ region: REGION }); export { pinClient };

엔드포인트에 대한 인앱 메시지를 검색합니다.

// Import required AWS SDK clients and commands for Node.js import { PinpointClient, GetInAppMessagesCommand } from "@aws-sdk/client-pinpoint"; import { pinClient } from "./lib/pinClient.js"; ("use strict"); //The Amazon Pinpoint application ID. const projectId = "4c545b28d21a490cb51b0b364example"; //The ID of the endpoint to retrieve messages for. const endpointId = "c5ac671ef67ee3ad164cf7706example"; const params = { ApplicationId: projectId, EndpointId: endpointId }; const run = async () => { try { const data = await pinClient.send(new GetInAppMessagesCommand(params)); console.log(JSON.stringify(data, null, 4)); return data; } catch (err) { console.log("Error", err); } }; run();
Python
import logging import boto3 from botocore.exceptions import ClientError logger = logging.getLogger(__name__) def retrieve_inapp_messages( pinpoint_client, project_id, endpoint_id): """ Retrieves the in-app messages that a given endpoint is entitled to. :param pinpoint_client: A Boto3 Pinpoint client. :param project_id: An Amazon Pinpoint project ID. :param endpoint_id: The ID of the endpoint to retrieve messages for. :return: A JSON object that contains information about the in-app message. """ try: response = pinpoint_client.get_in_app_messages( ApplicationId=project_id, EndpointId=endpoint_id) except ClientError: logger.exception("Couldn't retrieve messages.") raise else: return response def main(): project_id = "4c545b28d21a490cb51b0b364example" endpoint_id = "c5ac671ef67ee3ad164cf7706example" inapp_response = retrieve_inapp_messages( boto3.client('pinpoint'), project_id, endpoint_id) print(inapp_response) if __name__ == '__main__': main()