I just upgraded my Firebase Cocoapods from 3.15.0 to 4.0.4 and FirebaseAuth Cocoapods from 3.1.1 to 4.0.0.
I'm using email & password to authenticate users. When a user changes their email I was using this method below and everything was working fine:
FIREmailPasswordAuthProviderID.credential(withEmail: emailTextField.text!, password: passwordTextField.text!)
Now that I updated I get the error message
Value of type 'String' has no member 'credential'
I looked on the docs and it said to use the method below:
The problem is I get the same exact error:
FIREmailAuthProviderID.credential(withEmail: emailTextField.text!, password: passwordTextField.text!)
Value of type 'String' has no member 'credential'
My original code below
import Firebase
import FirebaseAuth
let user: User?
let credential = FIREmailPasswordAuthProviderID.credential(withEmail: emailTextField.text!, password: passwordTextField.text!)
if let user = user{
user.reauthenticate(with: credential, completion: {
(error) in
if error != nil{
//...do something
return
}
//...do something else
})
}
What am I doing wrong?
Hold up
FIREmailAuthProviderID is a constant that contains the auth providers id and is a string (which is EmailAuthProviderID in FB 4). There is no credential function which is why you are getting that error.
Here's a link to the Firebase 4 Migration Guide
The new format (and the correct function call) is
EmailAuthProvider.credential(withEmail email: String, password: String) -> AuthCredential
20171014 Edit: updated link to latest migration guide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With