//setup service config
AWSServiceConfiguration *serviceConfiguration = [[AWSServiceConfiguration alloc] initWithRegion:CognitoIdentityUserPoolRegion credentialsProvider:nil];
//create a pool
AWSCognitoIdentityUserPoolConfiguration *configuration = [[AWSCognitoIdentityUserPoolConfiguration alloc] initWithClientId:CognitoIdentityUserPoolAppClientId clientSecret:nil poolId:CognitoIdentityUserPoolId];
[AWSCognitoIdentityUserPool registerCognitoIdentityUserPoolWithConfiguration:serviceConfiguration userPoolConfiguration:configuration forKey:@"UserPool"];
AWSCognitoIdentityUserPool *pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:@"UserPool"];
pool.delegate = self;
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:CognitoIdentityUserPoolRegion
identityPoolId:CognitoIdentityPoolId];
AWSServiceConfiguration *configuration1 = [[AWSServiceConfiguration alloc] initWithRegion:CognitoIdentityUserPoolRegion
credentialsProvider:credentialsProvider];
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration1;
以上是我在 appdelegate 中的代码。我正在使用 AWS 文档“CognitoYourUserPool”中的示例登录。并尝试使用 Generated SDK for iOS 调用 API。
API_Client *apiInstance = [API_Client defaultClient];
[apiInstance setAPIKey:@"xxxxxxxxxxxxxxxxxxxxxx"];
[[apiInstance presetTypeGet] continueWithBlock:^id _Nullable(AWSTask * _Nonnull t) {
NSLog(@"error: %@",t.error);
NSLog(@"result: %@",t.result);
return nil;
}];
登录后我确实调用了 API。但这是错误的。我现在不知道为什么。请帮我。如果您需要更多信息,请询问。非常感谢你。