サポート終了通知: 2026 年 10 月 30 日、 AWS は Amazon Pinpoint のサポートを終了します。2026 年 10 月 30 日を過ぎると、Amazon Pinpoint コンソールまたは Amazon Pinpoint のリソース (エンドポイント、セグメント、キャンペーン、ジャーニー、分析) にアクセスできなくなります。詳細については、「Amazon Pinpoint のサポート終了」を参照してください。注: SMS、音声、モバイルプッシュ、OTP、電話番号の検証に関連する APIs は、この変更の影響を受けず、 AWS エンドユーザーメッセージングでサポートされています。
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
Amazon Pinpoint を使用してプログラムでエンドポイントのアプリケーション内のメッセージを取得する
アプリケーションは、GetInAppMessages API を呼び出すことで、指定されたエンドポイントに権利があるすべてのアプリケーション内のメッセージを取得することができます。GetInAppMessages API を呼び出す際には、以下のパラメータを指定します。
これらの値を指定して API を呼び出すと、メッセージの一覧が返されます。このオペレーションで生成されるレスポンスの詳細については、「GetInAppMessages Amazon Pinpoint API レスポンス JSON の例」を参照してください。
GetInAppMessages SDK を使用して AWS オペレーションを呼び出すことができます。次のコード例には、アプリケーション内のメッセージを取得する関数が含まれています。
- 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()