SMS 메시징 기본 설정 지정 - Amazon Simple Notification Service

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

SMS 메시징 기본 설정 지정

Amazon SNS를 사용하여 SMS 메시징에 대한 기본 설정을 지정합니다. 예를 들어 비용 또는 안정성을 위해 전송을 최적화할지 여부, 월별 지출 한도, 전송을 로그하는 방법 및 일일 SMS 사용 보고서를 구독할지 여부를 지정할 수 있습니다.

이러한 기본 설정은 계정에서 보내는 모든 SMS 메시지에 적용되지만, 개별 메시지를 전송할 때 일부 설정을 무시할 수 있습니다. 자세한 정보는 휴대폰에 게시을 참조하세요.

를 사용하여 SMS 메시징 기본 설정 지정 AWS Management Console

  1. Amazon SNS 콘솔에 로그인합니다.

  2. SMS 메시징을 지원하는 리전을 선택합니다.

  3. 탐색 창에서 모바일, 문자 메시지(SMS)를 선택합니다.

  4. 모바일 문자 메시지(SMS) 페이지의 문자 메시지 기본 설정 섹션에서 편집을 선택합니다.

  5. Edit text messaging preferences(문자 메시지 기본 설정 편집) 페이지의 세부 정보 섹션에서 다음을 수행합니다.

    1. 기본 메시지 유형에서 다음 중 하나를 선택합니다.

      • 프로모션 – 중요하지 않은 메시지(예: 마케팅)입니다. Amazon SNS는 최소 비용이 발생하도록 메시지 전송을 최적화합니다.

      • 트랜잭션(기본값) – 고객 트랜잭션을 지원하는 중요한 메시지입니다(예: 멀티 팩터 인증을 위한 일회용 암호). Amazon SNS는 최고의 안정성을 달성하도록 메시지 전송을 최적화합니다.

      프로모션 및 트랜잭션 메시지에 대한 요금 정보는 글로벌 SMS 요금에서 확인하세요.

    2. (선택 사항) 계정 지출 한도에 매월 SMS 메시지에 지출하려는 최대 금액(USD)을 입력합니다.

      중요
      • 기본적으로 지출 할당량은 1.00USD로 설정됩니다. 서비스 할당량을 늘리려면 요청을 제출하세요.

      • 콘솔에서 설정된 금액이 서비스 할당량을 초과할 경우 Amazon SNS에서 SMS 메시지 게시를 중지합니다.

      • Amazon SNS는 분산 시스템이므로 초과되는 지출 할당량(분) 이내에 SMS 메시지 전송을 중지합니다. 이 기간 사이에 SMS 메시지 전송을 계속하는 경우 할당량 초과 비용이 발생할 수 있습니다.

  6. (선택 사항) 기본 발신자 ID에 기업 브랜드와 같은 사용자 지정 ID를 입력합니다. 이 ID는 수신하는 디바이스의 발신자로 표시됩니다.

    참고

    발신자 ID에 대한 지원은 국가별로 다릅니다.

  7. (선택 사항) Amazon S3 bucket name for usage reports(사용 보고서용 Amazon S3 버킷 이름)의 이름을 입력합니다.

    참고

    S3 버킷 정책은 Amazon SNS에 쓰기 액세스 권한을 부여해야 합니다.

  8. 변경 사항 저장를 선택합니다.

환경설정 (AWS SDK) 지정

AWS SDK 중 하나를 사용하여 SMS 기본 설정을 지정하려면 Amazon SNS API의 SetSMSAttributes 요청에 해당하는 해당 SDK의 작업을 사용하십시오. 이 요청을 통해 월 지출 할당량 및 기본 SMS 유형(프로모션 또는 트랜잭션) 등의 다양한 SMS 속성에 값을 할당합니다. 모든 SMS 속성은 Amazon Simple Notification Service API 참조SetSMSAttributes를 참조하세요.

다음 코드 예제는 SetSMSAttributes의 사용 방법을 보여 줍니다.

C++
SDK for C++
참고

자세한 내용은 여기에서 확인할 수 있습니다. GitHub AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

Amazon SNS를 사용하여 DefaultSMSType 속성을 설정하는 방법입니다.

//! Set the default settings for sending SMS messages. /*! \param smsType: The type of SMS message that you will send by default. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SNS::setSMSType(const Aws::String &smsType, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SNS::SNSClient snsClient(clientConfiguration); Aws::SNS::Model::SetSMSAttributesRequest request; request.AddAttributes("DefaultSMSType", smsType); const Aws::SNS::Model::SetSMSAttributesOutcome outcome = snsClient.SetSMSAttributes( request); if (outcome.IsSuccess()) { std::cout << "SMS Type set successfully " << std::endl; } else { std::cerr << "Error while setting SMS Type: '" << outcome.GetError().GetMessage() << "'" << std::endl; } return outcome.IsSuccess(); }
  • API 세부 정보는 AWS SDK for C++ API 참조SetSMSAttributes를 참조하십시오.

CLI
AWS CLI

SMS 메시지 속성을 설정하려면

다음 set-sms-attributes 예제에서는 SMS 메시지의 기본 발신자 ID를 MyName으로 설정합니다.

aws sns set-sms-attributes \ --attributes DefaultSenderID=MyName

이 명령은 출력을 생성하지 않습니다.

  • API 세부 정보는 AWS CLI 명령 참조SetSMSAttributes를 참조하세요.

Java
SDK for Java 2.x
참고

더 많은 것이 있어요 GitHub. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.sns.SnsClient; import software.amazon.awssdk.services.sns.model.SetSmsAttributesRequest; import software.amazon.awssdk.services.sns.model.SetSmsAttributesResponse; import software.amazon.awssdk.services.sns.model.SnsException; import java.util.HashMap; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class SetSMSAttributes { public static void main(String[] args) { HashMap<String, String> attributes = new HashMap<>(1); attributes.put("DefaultSMSType", "Transactional"); attributes.put("UsageReportS3Bucket", "janbucket"); SnsClient snsClient = SnsClient.builder() .region(Region.US_EAST_1) .build(); setSNSAttributes(snsClient, attributes); snsClient.close(); } public static void setSNSAttributes(SnsClient snsClient, HashMap<String, String> attributes) { try { SetSmsAttributesRequest request = SetSmsAttributesRequest.builder() .attributes(attributes) .build(); SetSmsAttributesResponse result = snsClient.setSMSAttributes(request); System.out.println("Set default Attributes to " + attributes + ". Status was " + result.sdkHttpResponse().statusCode()); } catch (SnsException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }
  • API 세부 정보는 AWS SDK for Java 2.x API 참조SetSMSAttributes를 참조하십시오.

JavaScript
JavaScript (v3) 용 SDK
참고

더 많은 내용이 있습니다. GitHub AWS 코드 예시 리포지토리에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요.

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

import { SNSClient } from "@aws-sdk/client-sns"; // The AWS Region can be provided here using the `region` property. If you leave it blank // the SDK will default to the region set in your AWS config. export const snsClient = new SNSClient({});

SDK 및 클라이언트 모듈을 가져오고 API를 호출합니다.

import { SetSMSAttributesCommand } from "@aws-sdk/client-sns"; import { snsClient } from "../libs/snsClient.js"; /** * @param {"Transactional" | "Promotional"} defaultSmsType */ export const setSmsType = async (defaultSmsType = "Transactional") => { const response = await snsClient.send( new SetSMSAttributesCommand({ attributes: { // Promotional – (Default) Noncritical messages, such as marketing messages. // Transactional – Critical messages that support customer transactions, // such as one-time passcodes for multi-factor authentication. DefaultSMSType: defaultSmsType, }, }), ); console.log(response); // { // '$metadata': { // httpStatusCode: 200, // requestId: '1885b977-2d7e-535e-8214-e44be727e265', // extendedRequestId: undefined, // cfId: undefined, // attempts: 1, // totalRetryDelay: 0 // } // } return response; };
PHP
SDK for PHP
참고

더 많은 것이 있어요 GitHub. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

$SnSclient = new SnsClient([ 'profile' => 'default', 'region' => 'us-east-1', 'version' => '2010-03-31' ]); try { $result = $SnSclient->SetSMSAttributes([ 'attributes' => [ 'DefaultSMSType' => 'Transactional', ], ]); var_dump($result); } catch (AwsException $e) { // output error message if fails error_log($e->getMessage()); }