AWS Pinpointコマンドチートシート
Pinpointのコマンドでエンドポイント登録やメッセージ送信の方法です。前提としてfcm.jsonが存在しているとします。現時点では東京リージョンも対応されたようですが、オレゴン、コマンドプロンプト確認しました。
fcm.json
{
"ApplicationId": "hoge",
"EndpointId": "fuga",
"EndpointRequest": {
"Address": "devicetoken",
"ChannelType": "GCM",
"EffectiveDate": "2020-11-09T16:28:27+09:00",
"EndpointStatus": "ACTIVE",
"RequestId": ""
}
}
apns.json
{
"ApplicationId": "hoge",
"EndpointId": "fuga",
"EndpointRequest": {
"Address": "devicetoken",
"ChannelType": "APNS",
"EffectiveDate": "2020-11-09T16:28:27+09:00",
"EndpointStatus": "ACTIVE",
"RequestId": ""
}
}
エンドポイント登録(FCM)
エンドポイントを登録するにはupdate-endpointを使用します。
aws pinpoint update-endpoint --region us-west-2 --cli-input-json file://fcm.json
正常に登録出来たら「Accepted」となります。
{
"MessageBody": {
"Message": "Accepted",
"RequestID": "1bffb8b8-bd1e-40a1-a580-ea11dca5eea7"
}
}
EffectiveDateがISO8601フォーマットでない場合、「An error occurred (BadRequestException) when calling the UpdateEndpoint operation: EffectiveDate must be in ISO 8601 format」が発生します。
エンドポイント登録(APNS…)
APNSなどでもエンドポイントを登録するにはupdate-endpointを使用します。
aws pinpoint update-endpoint --region us-west-2 --cli-input-json file://apns.json
正常に登録出来たら「Accepted」となります。
{
"MessageBody": {
"Message": "Accepted",
"RequestID": "1bffb8b8-bd1e-40a1-a580-ea11dca5eea7"
}
}
エンドポイント情報取得
登録したエンドポイントの情報を取得するにはget-endpointを使用します。
aws pinpoint get-endpoint --application-id "hoge" --endpoint-id "fuga" --region us-west-2
application-idとendpoint-idは登録時にJSONファイルなどで指定した値を指定します。
{
"EndpointResponse": {
"EffectiveDate": "2020-11-09T16:28:27+09:00",
"OptOut": "NONE",
"RequestId": "97d7054a-60a6-4d74-8972-34dd4aeb4dxx",
"Address": "devicetoken",
"CohortId": "21",
"ChannelType": "GCM",
"CreationDate": "2020-11-09T16:28:27+09:00",
"ApplicationId": "hoge",
"Id": "fuga",
"EndpointStatus": "ACTIVE"
}
}
Addressにデバイストークンが設定されます。
エンドポイント削除
登録したエンドポイントを削除するにはdelete-endpointを使用します。
aws pinpoint delete-endpoint --application-id "hoge" --endpoint-id "fuga" --region us-west-2
application-idとendpoint-idは登録時にJSONファイルなどで指定した値を指定します。
{
"EndpointResponse": {
"ApplicationId": "hoge",
"Id": "fuga",
"RequestId": "3dda4da3-fcd6-43f1-a116-0fc0f67af9dh",
"EndpointStatus": "ACTIVE"
}
}
Addressにデバイストークンが設定されます。
{
"EndpointResponse": {
"ApplicationId": "hgoe",
"Id": "fuga",
"RequestId": "3dda4da3-fcd6-43f1-a116-0fc0f67af7ed",
"EndpointStatus": "ACTIVE"
}
}
get-endpointを実行すると削除されているので「An error occurred (NotFoundException) when calling the GetEndpoint operation: Resource not found」エラーになるはずです。

KHI入社して退社。今はCONFRAGEで正社員です。関西で140-170/80~120万から受け付けております^^
得意技はJS(ES20xx),Java,AWSの大体のリソースです
コメントはやさしくお願いいたします^^
座右の銘は、「狭き門より入れ」「願わくは、我に七難八苦を与えたまえ」です^^


コメント