简体   繁体   English

设备无法使用Firebase身份验证电话号码

[英]Device not working with Firebase Authentication Phone Number

I have an iPhone that I'm trying to use with firebase authentication using phone numbers. 我有一个iPhone,我正在尝试使用电话号码进行Firebase身份验证。

The project works and the emulator + device (without sim card) works using that phone number of the device that doesn't work (receives sms). 该项目有效,并且仿真器+设备(不带SIM卡)使用该无效设备的电话号码(接收短信)工作。 But when I try to "login" on the device (with sim) I keep getting nil from verifyPhoneNumber . 但是,当我尝试在设备上(使用sim卡)“登录”时,我总是从verifyPhoneNumber获取nil Is there something I'm missing that has to be active on the device? 我缺少必须在设备上激活的东西吗?

This is the code that I'm trying to call with the text field as +1**********, along with FirebaseApp.configure() in the AppDelegate 这是我尝试使用文本字段+1 **********以及AppDelegate中的FirebaseApp.configure()调用的代码

PhoneAuthProvider.provider().verifyPhoneNumber(phoneTextField.text!, uiDelegate: nil) { (veri, error) in
    if error != nil {
        print(veri)
    } else {
        print(error)
    }
}

There is likely an error, but it's not surfacing because the if statement is backwards. 可能存在错误,但是由于if语句是向后的,所以没有出现错误。 Instead, it should be 相反,它应该是

PhoneAuthProvider.provider().verifyPhoneNumber(phoneTextField.text!, uiDelegate: nil) { (veri, error) in
    if error != nil {
        print(error)
    } else {
        print(veri)
    }
}

This will then print error instead of veri . 然后,这将打印error而不是veri It's likely printing nil because veri has no value if there's an error. 可能会打印nil因为如果有错误, veri没有任何价值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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