Last active
July 11, 2017 12:50
-
-
Save cagdas1/21cca5bd4ddee7e06efc71d8a5027b10 to your computer and use it in GitHub Desktop.
AWS Cognito IOS-SDK for creating User
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment