这是从 Cognito 获取用户列表的工作代码。
//IAM User Key and Secret Key Required
let IAMUserKey = “****”
let IAMSecretKey = “****”
//Set Credentials
let credentialsProvider : AWSStaticCredentialsProvider = AWSStaticCredentialsProvider(accessKey: IAMUserKey, secretKey: IAMSecretKey)
let serviceConfiguration: AWSServiceConfiguration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialsProvider)
//Register Identity Provider
AWSCognitoIdentityProvider.register(with: serviceConfiguration, forKey:UserPoolID)
//Request
let getUsersRequest = AWSCognitoIdentityProviderListUsersRequest()
getUsersRequest?.userPoolId = UserPoolID
//mentioned name of attributes in array - name, given_name, username, email and so on
getUsersRequest?.attributesToGet = ["name"]
//Add Value in filter you want to search
getUsersRequest?.filter = "name = \”jen\””
//It will search string in including string
//getUsersRequest?.filter = "name ^= \"jen\""
AWSCognitoIdentityProvider(forKey: UserPoolID).listUsers(getUsersRequest!,completionHandler: {(response, error) in
print("response:\(String(describing: response))")
print("error:\(String(describing: error))")
})