PhoneAuthProvider
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *)
@objc(FIRPhoneAuthProvider)
open class PhoneAuthProvider : NSObject, @unchecked SendableA concrete implementation of AuthProvider for phone auth providers.
This class is available on iOS only.
-
A string constant identifying the phone identity provider.
Declaration
Swift
@objc public static let id: String -
Returns an instance of
PhoneAuthProviderfor the defaultAuthobject.Declaration
Swift
@objc(provider) open class func provider() -> PhoneAuthProvider -
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: (@MainActor (String?, Error?) -> Void)?)Parameters
phoneNumberThe phone number to be verified.
uiDelegateAn object used to present the SFSafariViewController. The object is retained by this method until the completion block is executed.
completionThe 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: (@MainActor (String?, Error?) -> Void)?)Parameters
phoneNumberThe phone number to be verified.
uiDelegateAn object used to present the SFSafariViewController. The object is retained by this method until the completion block is executed.
multiFactorSessionA 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.
completionThe 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 -> StringParameters
phoneNumberThe phone number to be verified.
uiDelegateAn object used to present the SFSafariViewController. The object is retained by this method until the completion block is executed.
multiFactorSessionA 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
multiFactorInfoThe phone multi factor whose number need to be verified.
uiDelegateAn object used to present the SFSafariViewController. The object is retained by this method until the completion block is executed.
multiFactorSessionA 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.
completionThe 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 -> StringParameters
multiFactorInfoThe phone multi factor whose number need to be verified.
uiDelegateAn object used to present the SFSafariViewController. The object is retained by this method until the completion block is executed.
multiFactorSessionA 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
AuthCredentialfor 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) -> PhoneAuthCredentialParameters
verificationIDThe verification ID obtained from invoking verifyPhoneNumber:completion:
verificationCodeThe verification code obtained from the user.
Return Value
The corresponding phone auth credential for the verification ID and verification code provided.