2017-01-09 87 views
0

我正在使用Amazon Web Services为iOS应用程序的用户进行身份验证。 我有一个屏幕用电话号码注册。当用户输入他的电话号码时,他会得到一个OTP代码,然后他将在验证屏幕中输入该代码。最后,验证无误后,App推送创建用户名&密码屏幕。这就是我想要的。 但是,亚马逊Web服务只提供注册方法如下:如何使用Cognito用户池注册用户 - Amazon Web Services没有用户名和密码

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 protected]"; 

//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; 
}]; 

正如你看到的,我一定要当我的电话号码注册创建用户名和密码。但我想创建用户名并稍后通过。谁能帮我解决这个问题?谢谢!

回答

1

截至2017年1月9日,Amazon Cognito不支持您描述的流程。

如果您改变了流程,您可以使用Cognito完成此操作: 使用用户名,密码和电话号码注册 - >应用程序用户收到验证码 - >应用程序用户提交验证码 - >应用程序用户注册/ 。

如果用户使用的电话号码已通过验证并且电话号码已启用“自动验证”,用户将只能登录。

您也可以使用别名来让您的用户与他们的电话号码登录: http://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#user-pool-settings-aliases

+0

谢谢!这也是我最后的解决方案 –