Skip to content

Instantly share code, notes, and snippets.

@cagdas1
Last active July 11, 2017 12:50
Show Gist options
  • Save cagdas1/21cca5bd4ddee7e06efc71d8a5027b10 to your computer and use it in GitHub Desktop.
Save cagdas1/21cca5bd4ddee7e06efc71d8a5027b10 to your computer and use it in GitHub Desktop.
AWS Cognito IOS-SDK for creating User
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