FirebaseAuth Framework Reference

PhoneAuthProvider

class PhoneAuthProvider : NSObject

A concrete implementation of AuthProvider for phone auth providers. This class is available on iOS only.

  • Returns an instance of PhoneAuthProvider for the default Auth object.

    Declaration

    Swift

    class func provider() -> Self
  • Returns an instance of PhoneAuthProvider for the provided Auth object.

    Declaration

    Swift

    class func provider(auth: FIRAuth) -> Self

    Parameters

    auth

    The auth object to associate with the phone auth provider instance.

  • Starts the phone number authentication flow by sending a verification code to the specified phone number.

    Declaration

    Swift

    func verifyPhoneNumber(_ phoneNumber: String, uiDelegate UIDelegate: FIRAuthUIDelegate?) async throws -> String

    Parameters

    phoneNumber

    The phone number to be verified.

    UIDelegate

    An object used to present the SFSafariViewController. The object is retained by this method until the completion block is executed.

    completion

    The callback to be invoked when the verification flow is finished. Possible error codes:

    • AuthErrorCodeCaptchaCheckFailed - Indicates that the reCAPTCHA token obtained by the Firebase Auth is invalid or has expired.
    • AuthErrorCodeQuotaExceeded - Indicates that the phone verification quota for this project has been exceeded.
    • AuthErrorCodeInvalidPhoneNumber - Indicates that the phone number provided is invalid.
    • AuthErrorCodeMissingPhoneNumber - Indicates that a phone number was not provided.
  • Verify ownership of the second factor phone number by the current user.

    Declaration

    Swift

    func verifyPhoneNumber(_ phoneNumber: String, uiDelegate UIDelegate: FIRAuthUIDelegate?, multiFactorSession session: FIRMultiFactorSession?) async throws -> String

    Parameters

    phoneNumber

    The phone number to be verified.

    UIDelegate

    An object used to present the SFSafariViewController. The object is retained by this method until the completion block is executed.

    session

    A session to identify the MFA flow. For enrollment, this identifies the user trying to enroll. For sign-in, this identifies that the user already passed the first factor challenge.

    completion

    The callback to be invoked when the verification flow is finished.

  • Verify ownership of the second factor phone number by the current user.

    Declaration

    Swift

    func verifyPhoneNumber(with phoneMultiFactorInfo: FIRPhoneMultiFactorInfo, uiDelegate UIDelegate: FIRAuthUIDelegate?, multiFactorSession session: FIRMultiFactorSession?) async throws -> String

    Parameters

    phoneMultiFactorInfo

    The phone multi factor whose number need to be verified.

    UIDelegate

    An object used to present the SFSafariViewController. The object is retained by this method until the completion block is executed.

    session

    A session to identify the MFA flow. For enrollment, this identifies the user trying to enroll. For sign-in, this identifies that the user already passed the first factor challenge.

    completion

    The callback to be invoked when the verification flow is finished.

  • Creates an AuthCredential for the phone number provider identified by the verification ID and verification code.

    Declaration

    Swift

    func credential(withVerificationID verificationID: String, verificationCode: String) -> FIRPhoneAuthCredential

    Parameters

    verificationID

    The verification ID obtained from invoking verifyPhoneNumber:completion:

    verificationCode

    The verification code obtained from the user.

    Return Value

    The corresponding phone auth credential for the verification ID and verification code provided.

  • Please use the provider() or provider(auth:) methods to obtain an instance of PhoneAuthProvider.