2017-01-09 84 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

謝謝!這也是我最後的解決方案 –