我正在使用 Amazon Web Services 对我的 iOS 应用程序的用户进行身份验证。 我有一个用电话号码注册的屏幕。当用户输入他的电话号码时,他会得到一个 OTP 代码,然后,他将在验证屏幕中输入该代码。最后,验证无误后,App 推送到创建用户名和密码屏幕。这就是我想要的。 但是,亚马逊网络服务只提供注册方法如下:
AWSCognitoIdentityUserAttributeType * phone = [AWSCognitoIdentityUserAttributeType new];
phone.name = @"phone_number";
//phone number must be prefixed by country code
phone.value = @"+15555555555";
AWSCognitoIdentityUserAttributeType * email = [AWSCognitoIdentityUserAttributeType new];
email.name = @"email";
email.value = @"email@mydomain.com";
//register the user
[[pool signUp:@"username" password:@"password" userAttributes:@[email,phone] validationData:nil] continueWithBlock:^id _Nullable(AWSTask<AWSCognitoIdentityUserPoolSignUpResponse *> * _Nonnull task) {
dispatch_async(dispatch_get_main_queue(), ^{
if(task.error){
[[[UIAlertView alloc] initWithTitle:task.error.userInfo[@"__type"]
message:task.error.userInfo[@"message"]
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil] show];
}else {
AWSCognitoIdentityUserPoolSignUpResponse * response = task.result;
if(!response.userConfirmed){
//need to confirm user using user.confirmUser:
}
}});
return nil;
}];
如您所见,我在使用电话号码注册时必须创建用户名和密码。但我想创建用户名并稍后通过。谁能帮我解决这个问题?谢谢!
最佳答案
截至 2017 年 1 月 9 日,Amazon Cognito 不支持您描述的流程。
如果您反转流程,您可以使用 Cognito 执行此操作: 使用用户名、密码和电话号码注册 -> 应用程序用户收到验证码 -> 应用程序用户提交验证码 -> 应用程序用户注册/登录。
用户只有在他们使用的电话号码经过验证并且为电话号码打开“自动验证”时才能登录。
您还可以使用别名让您的用户使用他们的电话号码登录: http://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#user-pool-settings-aliases
关于ios - 如何使用 Cognito 用户池注册用户 - 没有用户名和密码的 Amazon Web Services,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41545757/