4
votes

I am following the Firebase docs: https://firebase.google.com/docs/auth/ios/phone-auth

in an attempt to Authenticate with Firebase on iOS using a phone number and I am getting a fatal crash when it reaches here in my code:

PhoneAuthProvider.provider().verifyPhoneNumber(self.phoneNumberTextField.text!, uiDelegate: nil) { (verificationID, error) in 

    if let error = error {  
        print("error: \(error.localizedDescription)")
        return  
    }

    // Perform Seque to VerifictionCodeViewController
    self.performSegue(withIdentifier: "enterVerificationCode", sender: self)
}

The error is : libc++abi.dylib: terminating with uncaught exception of type NSException in my appDelegate.swift file.

If I use the older and 'deprecated' version of the function

PhoneAuthProvider.provider().verifyPhoneNumber(self.phoneNumberTextField.text!) { (verificationID, error) in 

    if let error = error {  
        print("error: \(error.localizedDescription)")
        return  
    }

    // Perform Seque to VerifictionCodeViewController
    self.performSegue(withIdentifier: "enterVerificationCode", sender: self)
}

without the new added uiDelegate: nil portion in the verifyPhoneNumber function, everything works fine!?

Has anyone been able to resolve this??

2
Also has this problem. So I'm using the old oneWYS

2 Answers

4
votes

You need to finish the rest of the settings.

reCAPTCHA verification: In the event that sending or receiving a silent push notification is not possible, such as when the user has disabled background refresh for your app, or when testing your app on an iOS simulator, Firebase Authentication uses reCAPTCHA verification to complete the phone sign-in flow. The reCAPTCHA challenge can often be completed without the user having to solve anything.

o enable the Firebase SDK to use reCAPTCHA verification:

Add custom URL schemes to your Xcode project: Open your project configuration: double-click the project name in the left tree view. Select your app from the TARGETS section, then select the Info tab, and expand the URL Types section. Click the + button, and add a URL scheme for your reversed client ID. To find this value, open the GoogleService-Info.plist configuration file, and look for the REVERSED_CLIENT_ID key. Copy the value of that key, and paste it into the URL Schemes box on the configuration page. Leave the other fields blank. When completed, your config should look something similar to the following (but with your application-specific values):

1
votes

you need to do what @mKane said and use reCaptcha verification ! and also you need to remove this key FirebaseAppDelegateProxyEnabled from info.plist ! this did the trick for me !