Swift 使用 AWSMobileClient 发送手机验证码
您可以使用 AWSMobileClient 的 sendSignInSMS 方法来发送手机验证码。以下是一个使用 Swift 编写的示例代码:
import AWSMobileClient
AWSMobileClient.default().sendSignInSMS { (signResult, error) in
if let error = error {
print('Error sending SMS: (error.localizedDescription)')
} else if let signResult = signResult {
print('SMS sent to (signResult.codeDeliveryDetails?.destination ?? '')')
}
}
请确保您已在项目中正确配置 AWSMobileClient,并在使用此代码之前初始化了 AWSMobileClient。此外,您需要在 AWS 控制台中配置 Amazon Cognito 用户池设置,以允许发送短信验证码。
原文地址: https://www.cveoy.top/t/topic/petd 著作权归作者所有。请勿转载和采集!