繁体   English   中英

Firebase电子邮件验证重定向网址

[英]Firebase Email Verification Redirect Url

我为我的iOS移动应用合并了Firebase's电子邮件验证,并试图解决以下问题:

  1. 重定向URL的长度看起来非常长。 看起来像是重复自己。

https://app.page.link?link=https://app.firebaseapp.com/ /auth/action?apiKey%3XXX%26mode%3DverifyEmail%26oobCode%3XXX%26continueUrl%3Dhttps://www.app.com /?verifyemail%253Demail@gmail.com%26lang%3Den&ibi=com.app.app&ifl=https://app.firebaseapp.com/ / auth / action?apiKey%3XXX%26mode%3DverifyEmail%26oobCode%3XXX%26continueUrl%3Dhttps :?//www.app.com/ verifyemail%253Demail@gmail.com%26lang%3Den

  1. 当我将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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM