我正在尝试使用AWSCognito用户池登录,但是未调用AWSCognitoIdentityInteractiveAuthenticationDelegate方法。这是我的代码,我在哪里做错了?
string numberToString(int n)
{
if (n == 0)
return "zero";
if (n == 1)
return "one";
if (n == 2)
return "two";
if (n == 3)
return "three";
if (n == 4)
return "four";
if (n == 5)
return "five";
if (n == 6)
return "six";
if (n == 7)
return "seven";
if (n == 8)
return "eight";
if (n == 9)
return "nine";
else
return "?";
}
预期结果:应该调用AWSCognitoIdentityInteractiveAuthenticationDelegate方法,并且应该关闭loginViewController。
答案 0 :(得分:1)
这是固定的方式:
将类LoginViewController
转换为AWSCognitoIdentityPasswordAuthentication
,并在同一类中添加以下功能
func startPasswordAuthentication() -> AWSCognitoIdentityPasswordAuthentication {
return self
}
在调用pool.clearAll()
之前添加self.user?.getSession()
答案 1 :(得分:0)
您需要致电
pool.clearAll()
执行登录过程之前
let authDetails = AWSCognitoIdentityPasswordAuthenticationDetails.init(username: email, password: password)
self.passwordAuthenticationCompletion?.set(result: authDetails)
self.user?.getSession()
如果您之前已经登录了该特定设备/模拟器,则AWS开发工具包将不会调用相应的方法。