我收到一个运行时错误,上面写着:
[NetworkInfo] 信号强度查询返回错误:Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied",描述符:
在我的代码中声明了变量“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)
以下是打印语句的调试窗口中的结果:
任务=
注册响应=无
用户=无
我在 AWS Cognito 控制台中检查了我的用户池。这一切都检查出来。我提供了用户池所需的所有必要信息。
这是游泳池的屏幕截图:
这个错误的原因是什么,我需要研究什么才能修复它?