[英]Firebase Email Verification Redirect Url
我为我的iOS
移动应用合并了Firebase's
电子邮件验证,并试图解决以下问题:
handleCodeInApp
设置为true时,并且当我单击重定向URL时被重定向回应用程序时,不会验证用户的电子邮件。 而当我将其设置为false并通过Firebase's
提供的Web小部件时,它确实得到了验证。 无法找到概述快速处理前者的文档... 任何想法表示赞赏。
func sendActivationEmail(_ user: User) {
let actionCodeSettings = ActionCodeSettings.init()
let redirectUrl = String(format: "https://www.app.com/?verifyemail=%@", user.email!)
actionCodeSettings.handleCodeInApp = true
actionCodeSettings.url = URL(string: redirectUrl)
actionCodeSettings.setIOSBundleID("com.app.app")
Auth.auth().currentUser?.sendEmailVerification(with: actionCodeSettings) { error in
guard error == nil else {
AlertController.showAlert(self, title: "Send Error", message: error!.localizedDescription)
return
}
}
}
确保您正在验证作为回调URL一部分的oobCode。
Auth.auth().applyActionCode(oobCode!, completion: { (err) in
if err == nil {
// reload the current user
}
})
完成此操作后,请在验证电子邮件后尝试从服务器重新加载用户的个人资料。
Auth.auth().currentUser?.reload(completion: {
(error) in
if(Auth.auth().currentUser?.isEmailVerified)! {
print("email verified")
} else {
print("email NOT verified")
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.