AWS SDK を使用して Amazon SNS プッシュ通知のプラットフォームエンドポイントを作成します。 - AWSSDK コードサンプル

AWSDocAWS SDKGitHub サンプルリポジトリには、さらに多くの SDK サンプルがあります

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

AWS SDK を使用して Amazon SNS プッシュ通知のプラットフォームエンドポイントを作成します。

次のコード例は、Amazon SNS プッシュ通知のプラットフォームエンドポイントを作成する方法を示しています。

Java
SDK for Java 2.x
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

public class RegistrationExample { public static void main(String[] args) { final String usage = "\n" + "Usage: " + " <token>\n\n" + "Where:\n" + " token - The name of the FIFO topic. \n\n" + " platformApplicationArn - The ARN value of platform application. You can get this value from the AWS Management Console. \n\n"; if (args.length != 2) { System.out.println(usage); System.exit(1); } String token = args[0]; String platformApplicationArn = args[1]; SnsClient snsClient = SnsClient.builder() .region(Region.US_EAST_1) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); createEndpoint(snsClient, token, platformApplicationArn); } public static void createEndpoint(SnsClient snsClient, String token, String platformApplicationArn){ System.out.println("Creating platform endpoint with token " + token); try { CreatePlatformEndpointRequest endpointRequest = CreatePlatformEndpointRequest.builder() .token(token) .platformApplicationArn(platformApplicationArn) .build(); CreatePlatformEndpointResponse response = snsClient.createPlatformEndpoint(endpointRequest); System.out.println("The ARN of the endpoint is " + response.endpointArn()); } catch ( SnsException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }