devsite/tools/jazzy/templates

FirebaseAuth Framework Reference

PhoneAuthProvider

@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *)
@objc(FIRPhoneAuthProvider)
open class PhoneAuthProvider : NSObject

A concrete implementation of AuthProvider for phone auth providers.

This class is available on iOS only.

  • id

    A string constant identifying the phone identity provider.

    Declaration

    Swift

    @objc
    public static let id: String
  • Returns an instance of PhoneAuthProvider for the default Auth object.

    Declaration

    Swift

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

    Declaration

    Swift

    @objc(providerWithAuth:)
    open class func provider(auth: Auth) -> PhoneAuthProvider

    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.

    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.

    Declaration

    Swift

    @objc(verifyPhoneNumber:UIDelegate:completion:)
    open func verifyPhoneNumber(_ phoneNumber: String,
                                uiDelegate: AuthUIDelegate? = nil,
                                completion: ((_: String?, _: Error?) -> Void)?)

    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.

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

    Declaration

    Swift

    @objc(verifyPhoneNumber:UIDelegate:multiFactorSession:completion:)
    open func verifyPhoneNumber(_ phoneNumber: String,
                                uiDelegate: AuthUIDelegate? = nil,
                                multiFactorSession: MultiFactorSession? = nil,
                                completion: ((_: String?, _: Error?) -> Void)?)

    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.

    multiFactorSession

    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

    @available(iOS 13, tvOS 13, macOS 10.15, watchOS 8, *)
    open func verifyPhoneNumber(_ phoneNumber: String,
                                uiDelegate: AuthUIDelegate? = nil,
                                multiFactorSession: MultiFactorSession? = nil) 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.

    multiFactorSession

    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.

    Return Value

    The verification ID

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

    Declaration

    Swift

    @objc(verifyPhoneNumberWithMultiFactorInfo:UIDelegate:multiFactorSession:completion:)
    open func verifyPhoneNumber(with multiFactorInfo: PhoneMultiFactorInfo,
                                uiDelegate: AuthUIDelegate? = nil,
                                multiFactorSession: MultiFactorSession?,
                                completion: ((_: String?, _: Error?) -> Void)?)

    Parameters

    multiFactorInfo

    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.

    multiFactorSession

    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

    @available(iOS 13, tvOS 13, macOS 10.15, watchOS 8, *)
    open func verifyPhoneNumber(with multiFactorInfo: PhoneMultiFactorInfo,
                                uiDelegate: AuthUIDelegate? = nil,
                                multiFactorSession: MultiFactorSession?) async throws -> String

    Parameters

    multiFactorInfo

    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.

    multiFactorSession

    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.

    Return Value

    The verification ID.

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

    Declaration

    Swift

    @objc(credentialWithVerificationID:verificationCode:)
    open func credential(withVerificationID verificationID: String,
                         verificationCode: String) -> PhoneAuthCredential

    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.