swift firebase phone auth error“verifyPhoneNumber:不推荐使用完成

时间:2017-09-28 09:28:05

标签: swift firebase firebase-authentication

错误“verifyPhoneNumber:不推荐使用

    PhoneAuthProvider.provider().verifyPhoneNumber(PhoneNum.text!) { (verificationID, error) in
        if let error = error {
            print(error.localizedDescription)

        }
        // Sign in using the verificationID and the code sent to the user
        else {
            UserDefaults.standard.set(verificationID, forKey: "authVerificationID")
            self.performSegue(withIdentifier: "segue", sender: self)
        }
    }

更新图片 enter image description here

1 个答案:

答案 0 :(得分:0)

我也遇到类似的问题,我按照@bojeil的链接进行操作,但我没有收到所有警告。 注意:我使用的是没有Pods的Firebase。 以下是我的代码:

let alert = UIAlertController(title: "Double-Check:", message: "Is this your correct mobile number? We'll send a text message with a confirmation code to this number:\n \(userMobileNumber.text!)", preferredStyle: .alert)

let action = UIAlertAction(title: "Yes, Send", style: .default) { 
    (alert: UIAlertAction!) in PhoneAuthProvider.provider().verifyPhoneNumber(fullMobileNumber, uiDelegate: nil) {
        (verificationID, error) in if error != nil {
            print("error: \(String(describing: error?.localizedDescription))")
        } else {
            let defaults = UserDefaults.standard
            defaults.set(verificationID, forKey: "authVID")
            // MARK:- Activity Indicator code begins

            // MARK:- Activity Indicator ends

            self.performSegue(withIdentifier: "verifyCode", sender: Any?.self)
        }
    }
}