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