1
私は、ユーザプールとアイデンティティをAWS Cognitoと統合するのに苦労しています。登録時やサインイン時にユーザーを認証する必要があるかどうかはわかりません。今、私のログイン方法はこのようになります。ユーザプールとアイデンティティプールの統合Objective-C
AWSCognitoIdentityUser *user = [self.pool getUser:self.emailField.text];
[[user getSession:self.emailField.text password:self.passwordField.text validationData:nil scopes:nil] continueWithBlock:^id _Nullable(AWSTask<AWSCognitoIdentityUserSession *> * _Nonnull task){
dispatch_async(dispatch_get_main_queue(), ^{
AWSServiceConfiguration *serviceConfiguration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil];
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:IdentityPool identityProviderManager:self.pool];
[credentialsProvider getIdentityId];
[credentialsProvider credentials];
if(task.error)
{
[SVProgressHUD dismiss];
UIAlertController *alert = [alertViewController passwordsDontMatch];
[self presentViewController:alert animated:YES completion:nil];
}
else
{
[SVProgressHUD dismiss];
[self performSegueWithIdentifier:@"Enter" sender:self];
}
});
これは私のAppDelegateです。
AWSServiceConfiguration *serviceConfiguration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil];
AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = serviceConfiguration;
AWSCognitoIdentityUserPoolConfiguration *configuration = [[AWSCognitoIdentityUserPoolConfiguration alloc] initWithClientId:ClientID clientSecret:ClientSecretId poolId:UserPoolId];
[AWSCognitoIdentityUserPool registerCognitoIdentityUserPoolWithConfiguration:serviceConfiguration userPoolConfiguration:configuration forKey:@"UserPool"];
AWSCognitoIdentityUserPool *pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:@"UserPool"];
self.credentialProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:IdentityPoolId];
AWSServiceConfiguration *config = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:self.credentialProvider];
AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = config;