Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 斯威夫特:我在firebase移动认证中遇到错误_Ios_Iphone_Firebase_Swift3_Firebase Authentication - Fatal编程技术网

Ios 斯威夫特:我在firebase移动认证中遇到错误

Ios 斯威夫特:我在firebase移动认证中遇到错误,ios,iphone,firebase,swift3,firebase-authentication,Ios,Iphone,Firebase,Swift3,Firebase Authentication,调用时出错 PhoneAuthProvider.provider().verifyPhoneNumber(txtmobile.text!) { (verificationID, error) in if error != nil { Model.shared.showAlert(msg: (error?.localizedDescription)!, vc: self) return } } 错误是令牌不匹配 首先将项目配置为fireba

调用时出错

PhoneAuthProvider.provider().verifyPhoneNumber(txtmobile.text!) { (verificationID, error) in
    if error != nil {
          Model.shared.showAlert(msg: (error?.localizedDescription)!, vc: self)
          return
    }
}
错误是令牌不匹配

首先将项目配置为firebase

在签名方法中的“身份验证”部分启用电话

通过拖放下载信息播放列表和加载项项目

安装所需的吊舱

添加中的应用程序委派

     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")
            }
      } 

详细解释。你能参考文档吗?你在添加设备令牌吗?是的,正确添加,也测试工作是否正常。通知来了。有什么问题吗??PhoneAuthProvider.provider.verifyPhoneNumberphoneNumber,uiDelegate:nil{firebase文档上的新版本正在导致我的应用程序崩溃。如果我删除uiDelegate:nil,它会工作!?PhoneAuthProvider.provider.verifyPhoneNumberself.phoneNumberTextField.text!,uiDelegate:nil{verificationID,if let error=error中的错误{printerror:\error.localizedDescription return}UserDefaults.standard.setverificationID,forKey:authVerificationID UserDefaults.standard.synchronize self.PerformsgueWithIdentifier:enterVerificationCode,发件人:self}