1
votes

I have an iPhone that I'm trying to use with firebase authentication using phone numbers.

The project works and the emulator + device (without sim card) works using that phone number of the device that doesn't work (receives sms). But when I try to "login" on the device (with sim) I keep getting nil from verifyPhoneNumber. 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

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

1 Answers

2
votes

There is likely an error, but it's not surfacing because the if statement is backwards. 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. It's likely printing nil because veri has no value if there's an error.