错误
PhoneAuthProvider.provider().verifyPhoneNumber(txtmobile.text!) { (verificationID, error) in
if error != nil {
Model.shared.showAlert(msg: (error?.localizedDescription)!, vc: self)
return
}
}
错误是"令牌不匹配"
答案 0 :(得分:-1)
首先将项目配置为firebase
在签名方法的身份验证部分启用电话
下载信息播放列表并通过拖放添加项目
安装必需的pod
app delegate in add
import Firebase
import FirebaseAuthUI
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
}
在视图控制器中,您需要验证电话号码
import FirebaseAuth
import FirebaseAuthUI
import FirebasePhoneAuthUI
class viewController: UIviewcontroller,FUIAuthDelegate {
override func viewDidLoad() {
super.viewDidLoad()
FUIAuth.defaultAuthUI()?.delegate = self
let phoneProvider = FUIPhoneAuth.init(authUI: FUIAuth.defaultAuthUI()!)
FUIAuth.defaultAuthUI()?.providers = [phoneProvider]
phoneProvider.signIn(withPresenting: self, phoneNumber: nil)
}
func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?) {
if let user = user {
print("I'm logged in")
}
else {
print(error?.localizedDescription ?? "Something went wrong")
}
}