gpt4 book ai didi

ios - 如何修复 AWSCognito 代码中的 "domainnsposixerrordomain code13 permission denied"运行时错误?

转载 作者:行者123 更新时间:2023-11-28 07:27:01 25 4
gpt4 key购买 nike

我收到一个运行时错误:

[NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor:

在我的代码中声明了变量“task”。我用注释标记了生成错误的行。

let serviceConfiguration: AWSServiceConfiguration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: nil)

//create a pool
let configuration: AWSCognitoIdentityUserPoolConfiguration = AWSCognitoIdentityUserPoolConfiguration(clientId: "6n3mb6nu0ls9ttfapkl69uuvd3", clientSecret: "7vlgp2ip3ihov4on7n0v4sti88sj6tfsobqlop6qu5t3db07bo6", poolId: "us-east-1_d0Y5gS66r")

AWSCognitoIdentityUserPool.register(with: serviceConfiguration, userPoolConfiguration: configuration, forKey: "AlarmMusic")
pool = AWSCognitoIdentityUserPool(forKey: "AlarmMusic")

let alertMessage = "Please register in order to be able to use this app:"

let alertController = UIAlertController(title: "Register", message: alertMessage, preferredStyle: .alert)

alertController.addTextField(configurationHandler: nil)
alertController.addTextField(configurationHandler: nil)
alertController.addTextField(configurationHandler: nil)

let actionOK = UIAlertAction(title: "OK", style: .cancel) {
action in

var attributes = [AWSCognitoIdentityUserAttributeType]()

let email: AWSCognitoIdentityUserAttributeType = AWSCognitoIdentityUserAttributeType(name: "email", value: alertController.textFields?[2].text ?? "olea.gnolaum@gmail.com")

attributes.append(email)

let task: AWSTask<AWSCognitoIdentityUserPoolSignUpResponse> = self.pool.signUp(alertController.textFields?[0].text ?? "dbrower", password: alertController.textFields?[1].text ?? "Password@1989", userAttributes: attributes, validationData: nil).continueOnSuccessWith( block: {_ in return nil }) as! AWSTask<AWSCognitoIdentityUserPoolSignUpResponse> // ERROR OCCURS HERE!

print("task=", task)

let signUpResponse: AWSCognitoIdentityUserPoolSignUpResponse? = task.result

print("signUpResponse=", signUpResponse as Any)

let user: AWSCognitoIdentityUser? = signUpResponse?.user

print("user=", user as Any)

}

alertController.addAction(actionOK)

self.present(alertController, animated: true, completion: nil)

以下是打印语句调试窗口中的结果:

task=

signUpResponse= nil

user= nil

我在 AWS Cognito 控制台中检查了我的用户池。这一切都检查出来了。我提供了用户池所需的所有必需信息。

这是池的屏幕截图:

enter image description here

此错误的原因是什么,我需要研究什么才能修复它?

最佳答案

这是一个如何从 Cognito 获取用户的小示例。

private func registerNewUser() {
let userPool = ...
let email = ...
let password = ...
let emailAttribute = AWSCognitoIdentityUserAttributeType(name: "email", value: email)
let attributes:[AWSCognitoIdentityUserAttributeType] = [emailAttribute]

userPool.signUp(email, password: password, userAttributes: attributes, validationData: nil).continueWith { (response) -> Any? in
if response.error != nil {
DispatchQueue.main.async {
let alert = UIAlertController(title: "Error", message: (response.error! as NSError).userInfo["message"] as? String, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler:nil))
self.present(alert, animated: true, completion: nil)
}
} else {
self.user = response.result!.user
}
return nil
}
}

关于ios - 如何修复 AWSCognito 代码中的 "domainnsposixerrordomain code13 permission denied"运行时错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56310161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com