Amazon Pinpoint へエンドポイントを追加する - Amazon Pinpoint

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

Amazon Pinpoint へエンドポイントを追加する

エンドポイントは、ユーザーのモバイルデバイスや電話番号、E メールアドレスなど、メッセージの送信先を表します。対象者のメンバーにメッセージを送信するには、メンバーごとにエンドポイントを 1 つ以上定義する必要があります。

エンドポイントを定義する際、チャンネルアドレスを指定します。チャンネルは、エンドポイントへのメッセージの送信に使用するプラットフォームのタイプです。チャンネルの例として、プッシュ通知サービス、SMS、E メールがあります。アドレスは、デバイストークン、電話番号、E メールアドレスなど、エンドポイントにメッセージを送信する場所を指定します。

対象者の詳細を追加するには、カスタム属性と標準属性を使用して、エンドポイントを強化します。これらの属性には、ユーザーやユーザーの設定、デバイスに加え、ユーザーが使用するクライアントのバージョンや、ユーザーの場所に関するデータが含まれます。このタイプのデータをエンドポイントに追加すると、次のことを実行できるようになります。

  • Amazon Pinpoint コンソールで対象者に関するグラフを表示する。

  • 適切な対象者にメッセージを送信できるように、エンドポイント属性に基づき、対象者を分類する。

  • エンドポイント属性値に置き換えられているメッセージ変数を組み込み、メッセージをパーソナライズする。

AWS Mobile SDK または AWS Amplify JavaScript ライブラリを使用して Amazon Pinpoint を統合すると、モバイルまたは JavaScript クライアントアプリケーションによってエンドポイントが自動的に登録されます。クライアントは、各新規ユーザーのエンドポイントを登録し、リピートユーザーのエンドポイントを更新します。モバイルまたは JavaScript クライアントからエンドポイントを登録するには、「アプリケーションでエンドポイントを登録する」を参照してください。

Amazon Pinpoint プロジェクトにエンドポイントを追加する方法を以下の例に示します。エンドポイントは、シアトル在住で iPhone を使用している対象メンバーを表します。このユーザーには、Apple Push Notification Service (APNs) を使用して、メッセージを送信できます。エンドポイントのアドレスは、APN より送信されるデバイストークンです。

AWS CLI

Amazon Pinpoint を使用するには、AWS CLI でコマンドを実行します。

例 Update Endpoint コマンド

エンドポイントを追加または更新するには、update-endpoint コマンドを使用します。

$ aws pinpoint update-endpoint \ > --application-id application-id \ > --endpoint-id endpoint-id \ > --endpoint-request file://endpoint-request-file.json

実行する条件は以下のとおりです。

  • application-id は、エンドポイントを追加または更新する Amazon Pinpoint プロジェクトの ID です。

  • example-endpoint は、新しいエンドポイントに割り当てる ID、または更新するエンドポイントの ID です。

  • endpoint-request-file.json は、ローカル JSON ファイルへのファイルパスを表しており、--endpoint-request パラメータの入力を含みます。

例 エンドポイントリクエストファイル

例の update-endpoint コマンドでは、--endpoint-request パラメータの引数として、JSON ファイルを使用します。このファイルには、次のようなエンドポイント定義が含まれます。

{ "ChannelType": "APNS", "Address": "1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7a8b9c0d1e2f", "Attributes": { "Interests": [ "Technology", "Music", "Travel" ] }, "Metrics": { "technology_interest_level": 9.0, "music_interest_level": 6.0, "travel_interest_level": 4.0 }, "Demographic": { "AppVersion": "1.0", "Make": "apple", "Model": "iPhone", "ModelVersion": "8", "Platform": "ios", "PlatformVersion": "11.3.1", "Timezone": "America/Los_Angeles" }, "Location": { "Country": "US", "City": "Seattle", "PostalCode": "98121", "Latitude": 47.61, "Longitude": -122.33 } }

エンドポイントのバッチの定義に使用する属性については、「Amazon Pinpoint API リファレンス」の「EndpointRequest スキーマ」を参照してください。

AWS SDK for Java

AWS SDK for Java が提供するクライアントにより、Java アプリケーションで Amazon Pinpoint API を使用できます。

例 Code

エンドポイントを追加するには、EndpointRequest オブジェクトを初期化し、AmazonPinpoint クライアントの updateEndpoint メソッドに渡します。

import com.amazonaws.regions.Regions; import com.amazonaws.services.pinpoint.AmazonPinpoint; import com.amazonaws.services.pinpoint.AmazonPinpointClientBuilder; import com.amazonaws.services.pinpoint.model.*; import java.util.Arrays; public class AddExampleEndpoint { public static void main(String[] args) { final String USAGE = "\n" + "AddExampleEndpoint - Adds an example endpoint to an Amazon Pinpoint application." + "Usage: AddExampleEndpoint <applicationId>" + "Where:\n" + " applicationId - The ID of the Amazon Pinpoint application to add the example " + "endpoint to."; if (args.length < 1) { System.out.println(USAGE); System.exit(1); } String applicationId = args[0]; // The device token assigned to the user's device by Apple Push Notification // service (APNs). String deviceToken = "1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7a8b9c0d1e2f"; // Initializes an endpoint definition with channel type and address. EndpointRequest wangXiulansIphoneEndpoint = new EndpointRequest() .withChannelType(ChannelType.APNS) .withAddress(deviceToken); // Adds custom attributes to the endpoint. wangXiulansIphoneEndpoint.addAttributesEntry("interests", Arrays.asList( "technology", "music", "travel")); // Adds custom metrics to the endpoint. wangXiulansIphoneEndpoint.addMetricsEntry("technology_interest_level", 9.0); wangXiulansIphoneEndpoint.addMetricsEntry("music_interest_level", 6.0); wangXiulansIphoneEndpoint.addMetricsEntry("travel_interest_level", 4.0); // Adds standard demographic attributes. wangXiulansIphoneEndpoint.setDemographic(new EndpointDemographic() .withAppVersion("1.0") .withMake("apple") .withModel("iPhone") .withModelVersion("8") .withPlatform("ios") .withPlatformVersion("11.3.1") .withTimezone("America/Los_Angeles")); // Adds standard location attributes. wangXiulansIphoneEndpoint.setLocation(new EndpointLocation() .withCountry("US") .withCity("Seattle") .withPostalCode("98121") .withLatitude(47.61) .withLongitude(-122.33)); // Initializes the Amazon Pinpoint client. AmazonPinpoint pinpointClient = AmazonPinpointClientBuilder.standard() .withRegion(Regions.US_EAST_1).build(); // Updates or creates the endpoint with Amazon Pinpoint. UpdateEndpointResult result = pinpointClient.updateEndpoint(new UpdateEndpointRequest() .withApplicationId(applicationId) .withEndpointId("example_endpoint") .withEndpointRequest(wangXiulansIphoneEndpoint)); System.out.format("Update endpoint result: %s\n", result.getMessageBody().getMessage()); } }
HTTP

HTTP リクエストを直接 REST API に送信して Amazon Pinpoint を使用することができます。

例 PUT Endpoint リクエスト

エンドポイントを追加するには、次の URI の Endpoint リソースに対して PUT リクエストを発行します。

/v1/apps/application-id/endpoints/endpoint-id

実行する条件は以下のとおりです。

  • application-id は、エンドポイントを追加または更新する Amazon Pinpoint プロジェクトの ID です。

  • endpoint-id は、新しいエンドポイントに割り当てる ID、または更新するエンドポイントの ID です。

リクエストに、必要なヘッダーを含め、EndpointRequest JSON を本文として指定します。

PUT /v1/apps/application_id/endpoints/example_endpoint HTTP/1.1 Host: pinpoint.us-east-1.amazonaws.com X-Amz-Date: 20180415T182538Z Content-Type: application/json Accept: application/json X-Amz-Date: 20180428T004705Z Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20180428/us-east-1/mobiletargeting/aws4_request, SignedHeaders=accept;content-length;content-type;host;x-amz-date, Signature=c25cbd6bf61bd3b3667c571ae764b9bf2d8af61b875cacced95d1e68d91b4170 Cache-Control: no-cache { "ChannelType": "APNS", "Address": "1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7a8b9c0d1e2f", "Attributes": { "Interests": [ "Technology", "Music", "Travel" ] }, "Metrics": { "technology_interest_level": 9.0, "music_interest_level": 6.0, "travel_interest_level": 4.0 }, "Demographic": { "AppVersion": "1.0", "Make": "apple", "Model": "iPhone", "ModelVersion": "8", "Platform": "ios", "PlatformVersion": "11.3.1", "Timezone": "America/Los_Angeles" }, "Location": { "Country": "US", "City": "Seattle", "PostalCode": "98121", "Latitude": 47.61, "Longitude": -122.33 } }

リクエストが成功すると、次のようなレスポンスが表示されます。

{ "RequestID": "67e572ed-41d5-11e8-9dc5-db288f3cbb72", "Message": "Accepted" }

Amazon Pinpoint API のエンドポイントリソースに関する詳細 (例: サポートされている HTTP メソッドやリクエストパラメータ) については、「Amazon Pinpoint API リファレンス」の「エンドポイント」を参照してください。

変数を使用したメッセージのパーソナライズの詳細については、「Amazon Pinpoint ユーザーガイド」の「メッセージ変数」を参照してください。

エンドポイントに適用するクォータに関する情報 (割り当て可能な属性の数など) については、「エンドポイントクォータ」を参照してください。