Swift AWS Cognito getSession
我正在尝试使用signup和getSession函数尽可能简单地记录用户。 在使用注册函数在同源用户池中创建新用户时,我没有遇到任何困难。 当我尝试创建用于日志记录的函数时,我会尝试以下代码:Swift AWS Cognito getSession,swift,amazon-web-services,aws-cognito,Swift,Amazon Web Services,Aws Cognito,我正在尝试使用signup和getSession函数尽可能简单地记录用户。 在使用注册函数在同源用户池中创建新用户时,我没有遇到任何困难。 当我尝试创建用于日志记录的函数时,我会尝试以下代码: func signin(){ let pool = AWSCognitoIdentityUserPool(forKey: AWSCognitoUserPoolSignInProviderKey) let user = pool.getUser("toto") user.get
func signin(){
let pool = AWSCognitoIdentityUserPool(forKey: AWSCognitoUserPoolSignInProviderKey)
let user = pool.getUser("toto")
user.getSession("toto", password: "BabaBobo1&", validationData: nil).continueWith(block: {[weak self] (task) -> Any? in
DispatchQueue.main.async {
if let error = task.error as? NSError {
let alertController = UIAlertController(title: error.userInfo["__type"] as? String,
message: error.userInfo["message"] as? String,
preferredStyle: .alert)
let retryAction = UIAlertAction(title: "Retry", style: .default, handler: nil)
alertController.addAction(retryAction)
self?.present(alertController, animated: true, completion: nil)
}else if let session = task.result {
let alertController = UIAlertController(title: "token",
message: session.accessToken?.tokenString,
preferredStyle: .alert)
let OKAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alertController.addAction(OKAction)
self?.present(alertController, animated: true, completion: nil)
}
}
return nil
})
}
似乎永远不会执行后续块。有人知道我做错了什么吗?
我的目标是将AWS链接代码减少到最小。我希望尽可能避免使用SDK中提供的不同代理协议如何解决此问题?