0
好吧,我开始与AWS Cognito工作,被困在用户注册......AWS Pool.Signup不会在雨燕的内部块执行代码3
这是我的问题是发生了什么:
func register(userNameChosen:String, attributes:[AWSCognitoIdentityUserAttributeType]) {
let task = self.pool.signUp(userNameChosen, password: senhaTextField.text!, userAttributes: attributes, validationData: nil)
task.continue(with: AWSExecutor.default(), with: { (task) -> Any? in
if task.error != nil { //error occur
let alert:UIAlertController = UIAlertController(title: "Error", message: task.error?.localizedDescription, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
} else { //no error
print("no error")
let response:AWSCognitoIdentityUserPoolSignUpResponse = task.result! as AWSCognitoIdentityUserPoolSignUpResponse
self.user = response.user
if response.userConfirmed as! Int != AWSCognitoIdentityUserStatus.confirmed.rawValue { //user not confirmed via email
//setup para mandar atraves de Segue
self.sentTo = response.codeDeliveryDetails?.destination
self.performSegue(withIdentifier: "confirmSignUp", sender: self)
} else {
print("User already confirmed?")
self.navigationController?.popToRootViewController(animated: true) //back to login
}
}
return nil
}).waitUntilFinished()
}
问题是,下面
task.continue(with: AWSExecutor.default(), with: { (task) -> Any? in
代码将无法执行...... 该应用程序已与AWS沟通好。当我使用“登录可选”运行它时,即使未经身份验证,它也会获得AWS令牌。但是,当我设置登录到移动需要集线器 - Cognito,我收到以下消息(这我不认为是问题的一部分,因为之前你注册,你显然未认证):
[26851:2009541] AWSiOSSDK v2.4.9 [Error] AWSIdentityProvider.m line:304 | __52-[AWSCognitoCredentialsProviderHelper getIdentityId]_block_invoke255 | GetId failed. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=8 "(null)" UserInfo={__type=NotAuthorizedException, message=Unauthenticated access is not supported for this identity pool.}]
或者
[26851:2009539] [] -[NWConcrete_tcp_connection dealloc] 1
2016-10-04 21:02:33.759918 App Aws[26851:2009462] subsystem: com.apple.UIKit, category: Touch, enable_level: 0, persist_level: 0, default_ttl: 1, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1, privacy_setting: 2, enable_private_data: 0