gpt4 book ai didi

ios - Firebase iOS : Second tap is working properly in login page

转载 作者:行者123 更新时间:2023-11-30 10:26:57 25 4
gpt4 key购买 nike

我决定让它尽可能简单。有人可以解释为什么我的代码第一次点击 Path_4 消息(坏路径),但在第二、第三、第四次点击 Path_2 和 Path3 消息(好路径)?有一些代码:

// Login

Auth.auth().signIn(withEmail: userEmail, password: userPassword) { [weak self] authResult, error in
guard self != nil else { return }
}

// Check user if verified

if ( Auth.auth().currentUser != nil ) {
Auth.auth().currentUser!.reload(completion: { (error) in

if let error = error {
self.displayAlertMessage(alertTitle: "1", alertMessage: "Path_1");
print(error)
} else {
if Auth.auth().currentUser!.isEmailVerified {
self.displayAlertMessage(alertTitle: "2", alertMessage: "Path_2");
} else {
//TODO Verification page
self.displayAlertMessage(alertTitle: "3", alertMessage: "Path_3");
}
}
})
} else {
self.displayAlertMessage(alertTitle: "4", alertMessage: "Path_4");
}

最佳答案

好吧,我尝试了类似的方法,但我认为这不是最好的方法:

   // Login

Auth.auth().signIn(withEmail: userEmail, password: userPassword) { [weak self] authResult, error in
guard self != nil else { return }
}

// Check user if verified

DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) { // Change `2.0` to the desired number of seconds.
if ( Auth.auth().currentUser != nil ) {
Auth.auth().currentUser!.reload(completion: { (error) in

if let error = error {
self.displayAlertMessage(alertTitle: "1", alertMessage: "Path_1");
print(error)
} else {
if Auth.auth().currentUser!.isEmailVerified {
self.displayAlertMessage(alertTitle: "2", alertMessage: "Path_2");
} else {
//TODO Verification page
self.displayAlertMessage(alertTitle: "3", alertMessage: "Path_3");
}
}
})
} else {
self.displayAlertMessage(alertTitle: "4", alertMessage: "Path_4");
}
}

我可以做些什么来暂停,直到登录操作尚未完成?

关于ios - Firebase iOS : Second tap is working properly in login page,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59973726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com