Auth
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *)
@preconcurrency
@objc(FIRAuth)
open class Auth : NSObjectextension Auth: UISceneDelegateextension Auth: UIApplicationDelegateextension Auth: AuthInteropManages authentication for Firebase apps.
This class is thread-safe.
- 
                  
                  
Gets the auth object for the default Firebase app.
The default Firebase app must have already been configured or an exception will be raised.
Declaration
Swift
@objc open class func auth() -> Auth - 
                  
                  
Gets the auth object for a
FirebaseApp.Declaration
Swift
@objc open class func auth(app: FirebaseApp) -> AuthParameters
appThe app for which to retrieve the associated
Authinstance.Return Value
The
Authinstance associated with the given app. - 
                  
                  
Gets the
FirebaseAppobject that this auth object is connected to.Declaration
Swift
@objc public internal(set) weak var app: FirebaseApp? { get } - 
                  
                  
Synchronously gets the cached current user, or null if there is none.
Declaration
Swift
@objc public var currentUser: User? { get } - 
                  
                  
The current user language code.
This property can be set to the app’s current language by calling
useAppLanguage().The string used to set this property must be a language code that follows BCP 47.
Declaration
Swift
@objc open var languageCode: String? { get set } - 
                  
                  
Contains settings related to the auth object.
Declaration
Swift
@NSCopying @objc open var settings: AuthSettings? - 
                  
                  
The current user access group that the Auth instance is using.
Default is
nil.Declaration
Swift
@objc public internal(set) var userAccessGroup: String? { get } - 
                  
                  
Contains shareAuthStateAcrossDevices setting related to the auth object.
If userAccessGroup is not set, setting shareAuthStateAcrossDevices will have no effect. You should set shareAuthStateAcrossDevices to its desired state and then set the userAccessGroup after.
Declaration
Swift
@objc open var shareAuthStateAcrossDevices: Bool - 
                  
                  
The tenant ID of the auth instance.
nilif none is available.Declaration
Swift
@objc open var tenantID: String? - 
                  
                  
The custom authentication domain used to handle all sign-in redirects. End-users will see this domain when signing in. This domain must be allowlisted in the Firebase Console.
Declaration
Swift
@objc open var customAuthDomain: String? - 
                  
                  
Sets the
currentUseron the receiver to the provided user object.Declaration
Swift
@objc open func updateCurrentUser(_ user: User?, completion: ((Error?) -> Void)? = nil)Parameters
userThe user object to be set as the current user of the calling Auth instance.
completionOptionally; a block invoked after the user of the calling Auth instance has been updated or an error was encountered.
 - 
                  
                  
Sets the
currentUseron the receiver to the provided user object.Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) open func updateCurrentUser(_ user: User) async throwsParameters
userThe user object to be set as the current user of the calling Auth instance.
 - 
                  
                  
[Deprecated] Fetches the list of all sign-in methods previously used for the provided email address. This method returns an empty list when Email Enumeration Protection is enabled, irrespective of the number of authentication methods available for the given email.
Possible error codes:
AuthErrorCodeInvalidEmail- Indicates the email address is malformed.Declaration
Swift
@available(*, deprecated, message: "`fetchSignInMethods` is deprecated and will be removed in a future release. This method returns an empty list when Email Enumeration Protection is enabled.") @objc open func fetchSignInMethods(forEmail email: String, completion: (([String]?, Error?) -> Void)? = nil)Parameters
emailThe email address for which to obtain a list of sign-in methods.
completionOptionally; a block which is invoked when the list of sign in methods for the specified email address is ready or an error was encountered. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
[Deprecated] Fetches the list of all sign-in methods previously used for the provided email address. This method returns an empty list when Email Enumeration Protection is enabled, irrespective of the number of authentication methods available for the given email.
Possible error codes:
AuthErrorCodeInvalidEmail- Indicates the email address is malformed.Declaration
Swift
@available(*, deprecated, message: "`fetchSignInMethods` is deprecated and will be removed in a future release. This method returns an empty list when Email Enumeration Protection is enabled.") open func fetchSignInMethods(forEmail email: String) async throws -> [String]Parameters
emailThe email address for which to obtain a list of sign-in methods.
Return Value
List of sign-in methods
 - 
                  
                  
Signs in using an email address and password.
When Email Enumeration Protection is enabled, this method fails with an error in case of an invalid email/password.
Possible error codes:
AuthErrorCodeOperationNotAllowed- Indicates that email and password accounts are not enabled. Enable them in the Auth section of the Firebase console.AuthErrorCodeUserDisabled- Indicates the user’s account is disabled.AuthErrorCodeWrongPassword- Indicates the user attempted sign in with an incorrect password.AuthErrorCodeInvalidEmail- Indicates the email address is malformed.
Declaration
Swift
@objc open func signIn(withEmail email: String, password: String, completion: ((AuthDataResult?, Error?) -> Void)? = nil)Parameters
emailThe user’s email address.
passwordThe user’s password.
completionOptionally; a block which is invoked when the sign in flow finishes, or is canceled. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Signs in using an email address and password.
Possible error codes:
AuthErrorCodeOperationNotAllowed- Indicates that email and password accounts are not enabled. Enable them in the Auth section of the Firebase console.AuthErrorCodeUserDisabled- Indicates the user’s account is disabled.AuthErrorCodeWrongPassword- Indicates the user attempted sign in with an incorrect password.AuthErrorCodeInvalidEmail- Indicates the email address is malformed.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) @discardableResult open func signIn(withEmail email: String, password: String) async throws -> AuthDataResultParameters
emailThe user’s email address.
passwordThe user’s password.
Return Value
The
AuthDataResultafter a successful signin. - 
                  
                  
Signs in using an email address and email sign-in link.
Possible error codes:
AuthErrorCodeOperationNotAllowed- Indicates that email and password accounts are not enabled. Enable them in the Auth section of the Firebase console.AuthErrorCodeUserDisabled- Indicates the user’s account is disabled.AuthErrorCodeWrongPassword- Indicates the user attempted sign in with an incorrect password.AuthErrorCodeInvalidEmail- Indicates the email address is malformed.
Declaration
Swift
@objc open func signIn(withEmail email: String, link: String, completion: ((AuthDataResult?, Error?) -> Void)? = nil)Parameters
emailThe user’s email address.
linkThe email sign-in link.
completionOptionally; a block which is invoked when the sign in flow finishes, or is canceled. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Signs in using an email address and email sign-in link. Possible error codes:
AuthErrorCodeOperationNotAllowed- Indicates that email and password accounts are not enabled. Enable them in the Auth section of the Firebase console.AuthErrorCodeUserDisabled- Indicates the user’s account is disabled.AuthErrorCodeWrongPassword- Indicates the user attempted sign in with an incorrect password.AuthErrorCodeInvalidEmail- Indicates the email address is malformed.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) open func signIn(withEmail email: String, link: String) async throws -> AuthDataResultParameters
emailThe user’s email address.
linkThe email sign-in link.
Return Value
The
AuthDataResultafter a successful signin. - 
                  
                  
Signs in using the provided auth provider instance.
Possible error codes:
AuthErrorCodeOperationNotAllowed- Indicates that email and password accounts are not enabled. Enable them in the Auth section of the Firebase console.AuthErrorCodeUserDisabled- Indicates the user’s account is disabled.AuthErrorCodeWrongPassword- Indicates the user attempted sign in with an incorrect password.AuthErrorCodeWebNetworkRequestFailed- Indicates that a network request within a SFSafariViewController or WKWebView failed.AuthErrorCodeWebInternalError- Indicates that an internal error occurred within a SFSafariViewController or WKWebView.AuthErrorCodeWebSignInUserInteractionFailure- Indicates a general failure during a web sign-in flow.AuthErrorCodeWebContextAlreadyPresented- Indicates that an attempt was made to present a new web context while one was already being presented.AuthErrorCodeWebContextCancelled- Indicates that the URL presentation was cancelled prematurely by the user.AuthErrorCodeAccountExistsWithDifferentCredential- Indicates the email asserted by the credential (e.g. the email in a Facebook access token) is already in use by an existing account, that cannot be authenticated with this sign-in method. Call fetchProvidersForEmail for this user’s email and then prompt them to sign in with any of the sign-in providers returned. This error will only be thrown if the “One account per email address” setting is enabled in the Firebase console, under Auth settings.
Declaration
Swift
@available(tvOS, unavailable) @available(macOS, unavailable) @available(watchOS, unavailable) @objc(signInWithProvider:UIDelegate:completion:) open func signIn(with provider: FederatedAuthProvider, uiDelegate: AuthUIDelegate?, completion: ((AuthDataResult?, Error?) -> Void)?)Parameters
providerAn instance of an auth provider used to initiate the sign-in flow.
uiDelegateOptionally an instance of a class conforming to the AuthUIDelegate protocol, this is used for presenting the web context. If nil, a default AuthUIDelegate will be used.
completionOptionally; a block which is invoked when the sign in flow finishes, or is canceled. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Signs in using the provided auth provider instance.
Possible error codes:
AuthErrorCodeOperationNotAllowed- Indicates that email and password accounts are not enabled. Enable them in the Auth section of the Firebase console.AuthErrorCodeUserDisabled- Indicates the user’s account is disabled.AuthErrorCodeWrongPassword- Indicates the user attempted sign in with an incorrect password.AuthErrorCodeWebNetworkRequestFailed- Indicates that a network request within a SFSafariViewController or WKWebView failed.AuthErrorCodeWebInternalError- Indicates that an internal error occurred within a SFSafariViewController or WKWebView.AuthErrorCodeWebSignInUserInteractionFailure- Indicates a general failure during a web sign-in flow.AuthErrorCodeWebContextAlreadyPresented- Indicates that an attempt was made to present a new web context while one was already being presented.AuthErrorCodeWebContextCancelled- Indicates that the URL presentation was cancelled prematurely by the user.AuthErrorCodeAccountExistsWithDifferentCredential- Indicates the email asserted by the credential (e.g. the email in a Facebook access token) is already in use by an existing account, that cannot be authenticated with this sign-in method. Call fetchProvidersForEmail for this user’s email and then prompt them to sign in with any of the sign-in providers returned. This error will only be thrown if the “One account per email address” setting is enabled in the Firebase console, under Auth settings.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) @available(tvOS, unavailable) @available(macOS, unavailable) @available(watchOS, unavailable) @discardableResult open func signIn(with provider: FederatedAuthProvider, uiDelegate: AuthUIDelegate?) async throws -> AuthDataResultParameters
providerAn instance of an auth provider used to initiate the sign-in flow.
uiDelegateOptionally an instance of a class conforming to the AuthUIDelegate protocol, this is used for presenting the web context. If nil, a default AuthUIDelegate will be used.
Return Value
The
AuthDataResultafter the successful signin. - 
                  
                  
Asynchronously signs in to Firebase with the given 3rd-party credentials (e.g. a Facebook login Access Token, a Google ID Token/Access Token pair, etc.) and returns additional identity provider data.
Possible error codes:
AuthErrorCodeInvalidCredential- Indicates the supplied credential is invalid. This could happen if it has expired or it is malformed.AuthErrorCodeOperationNotAllowed- Indicates that accounts with the identity provider represented by the credential are not enabled. Enable them in the Auth section of the Firebase console.AuthErrorCodeAccountExistsWithDifferentCredential- Indicates the email asserted by the credential (e.g. the email in a Facebook access token) is already in use by an existing account, that cannot be authenticated with this sign-in method. Call fetchProvidersForEmail for this user’s email and then prompt them to sign in with any of the sign-in providers returned. This error will only be thrown if the “One account per email address” setting is enabled in the Firebase console, under Auth settings.AuthErrorCodeUserDisabled- Indicates the user’s account is disabled.AuthErrorCodeWrongPassword- Indicates the user attempted sign in with an incorrect password, if credential is of the type EmailPasswordAuthCredential.AuthErrorCodeInvalidEmail- Indicates the email address is malformed.AuthErrorCodeMissingVerificationID- Indicates that the phone auth credential was created with an empty verification ID.AuthErrorCodeMissingVerificationCode- Indicates that the phone auth credential was created with an empty verification code.AuthErrorCodeInvalidVerificationCode- Indicates that the phone auth credential was created with an invalid verification Code.AuthErrorCodeInvalidVerificationID- Indicates that the phone auth credential was created with an invalid verification ID.AuthErrorCodeSessionExpired- Indicates that the SMS code has expired.
Declaration
Swift
@objc(signInWithCredential:completion:) open func signIn(with credential: AuthCredential, completion: ((AuthDataResult?, Error?) -> Void)? = nil)Parameters
credentialThe credential supplied by the IdP.
completionOptionally; a block which is invoked when the sign in flow finishes, or is canceled. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Asynchronously signs in to Firebase with the given 3rd-party credentials (e.g. a Facebook login Access Token, a Google ID Token/Access Token pair, etc.) and returns additional identity provider data.
Possible error codes:
AuthErrorCodeInvalidCredential- Indicates the supplied credential is invalid. This could happen if it has expired or it is malformed.AuthErrorCodeOperationNotAllowed- Indicates that accounts with the identity provider represented by the credential are not enabled. Enable them in the Auth section of the Firebase console.AuthErrorCodeAccountExistsWithDifferentCredential- Indicates the email asserted by the credential (e.g. the email in a Facebook access token) is already in use by an existing account, that cannot be authenticated with this sign-in method. Call fetchProvidersForEmail for this user’s email and then prompt them to sign in with any of the sign-in providers returned. This error will only be thrown if the “One account per email address” setting is enabled in the Firebase console, under Auth settings.AuthErrorCodeUserDisabled- Indicates the user’s account is disabled.AuthErrorCodeWrongPassword- Indicates the user attempted sign in with an incorrect password, if credential is of the type EmailPasswordAuthCredential.AuthErrorCodeInvalidEmail- Indicates the email address is malformed.AuthErrorCodeMissingVerificationID- Indicates that the phone auth credential was created with an empty verification ID.AuthErrorCodeMissingVerificationCode- Indicates that the phone auth credential was created with an empty verification code.AuthErrorCodeInvalidVerificationCode- Indicates that the phone auth credential was created with an invalid verification Code.AuthErrorCodeInvalidVerificationID- Indicates that the phone auth credential was created with an invalid verification ID.AuthErrorCodeSessionExpired- Indicates that the SMS code has expired.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) @discardableResult open func signIn(with credential: AuthCredential) async throws -> AuthDataResultParameters
credentialThe credential supplied by the IdP.
Return Value
The
AuthDataResultafter the successful signin. - 
                  
                  
Asynchronously creates and becomes an anonymous user.
If there is already an anonymous user signed in, that user will be returned instead. If there is any other existing user signed in, that user will be signed out.
Possible error codes:
AuthErrorCodeOperationNotAllowed- Indicates that anonymous accounts are not enabled. Enable them in the Auth section of the Firebase console.
Declaration
Swift
@objc open func signInAnonymously(completion: ((AuthDataResult?, Error?) -> Void)? = nil)Parameters
completionOptionally; a block which is invoked when the sign in finishes, or is canceled. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Asynchronously creates and becomes an anonymous user.
If there is already an anonymous user signed in, that user will be returned instead. If there is any other existing user signed in, that user will be signed out.
Possible error codes:
AuthErrorCodeOperationNotAllowed- Indicates that anonymous accounts are not enabled. Enable them in the Auth section of the Firebase console.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) @discardableResult @objc open func signInAnonymously() async throws -> AuthDataResultReturn Value
The
AuthDataResultafter the successful signin. - 
                  
                  
Asynchronously signs in to Firebase with the given Auth token.
Possible error codes:
AuthErrorCodeInvalidCustomToken- Indicates a validation error with the custom token.AuthErrorCodeCustomTokenMismatch- Indicates the service account and the API key belong to different projects.
Declaration
Swift
@objc open func signIn(withCustomToken token: String, completion: ((AuthDataResult?, Error?) -> Void)? = nil)Parameters
tokenA self-signed custom auth token.
completionOptionally; a block which is invoked when the sign in finishes, or is canceled. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Asynchronously signs in to Firebase with the given Auth token.
Possible error codes:
AuthErrorCodeInvalidCustomToken- Indicates a validation error with the custom token.AuthErrorCodeCustomTokenMismatch- Indicates the service account and the API key belong to different projects.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) @discardableResult open func signIn(withCustomToken token: String) async throws -> AuthDataResultParameters
tokenA self-signed custom auth token.
Return Value
The
AuthDataResultafter the successful signin. - 
                  
                  
Creates and, on success, signs in a user with the given email address and password.
Possible error codes:
AuthErrorCodeInvalidEmail- Indicates the email address is malformed.AuthErrorCodeEmailAlreadyInUse- Indicates the email used to attempt sign up already exists. Call fetchProvidersForEmail to check which sign-in mechanisms the user used, and prompt the user to sign in with one of those.AuthErrorCodeOperationNotAllowed- Indicates that email and password accounts are not enabled. Enable them in the Auth section of the Firebase console.AuthErrorCodeWeakPassword- Indicates an attempt to set a password that is considered too weak. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo dictionary object will contain more detailed explanation that can be shown to the user.
Declaration
Swift
@objc open func createUser(withEmail email: String, password: String, completion: ((AuthDataResult?, Error?) -> Void)? = nil)Parameters
emailThe user’s email address.
passwordThe user’s desired password.
completionOptionally; a block which is invoked when the sign up flow finishes, or is canceled. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Creates and, on success, signs in a user with the given email address and password.
Possible error codes:
AuthErrorCodeInvalidEmail- Indicates the email address is malformed.AuthErrorCodeEmailAlreadyInUse- Indicates the email used to attempt sign up already exists. Call fetchProvidersForEmail to check which sign-in mechanisms the user used, and prompt the user to sign in with one of those.AuthErrorCodeOperationNotAllowed- Indicates that email and password accounts are not enabled. Enable them in the Auth section of the Firebase console.AuthErrorCodeWeakPassword- Indicates an attempt to set a password that is considered too weak. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo dictionary object will contain more detailed explanation that can be shown to the user.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) @discardableResult open func createUser(withEmail email: String, password: String) async throws -> AuthDataResultParameters
emailThe user’s email address.
passwordThe user’s desired password.
Return Value
The
AuthDataResultafter the successful signin. - 
                  
                  
Resets the password given a code sent to the user outside of the app and a new password for the user.
Possible error codes:
AuthErrorCodeWeakPassword- Indicates an attempt to set a password that is considered too weak.AuthErrorCodeOperationNotAllowed- Indicates the administrator disabled sign in with the specified identity provider.AuthErrorCodeExpiredActionCode- Indicates the OOB code is expired.AuthErrorCodeInvalidActionCode- Indicates the OOB code is invalid.
Declaration
Swift
@objc open func confirmPasswordReset(withCode code: String, newPassword: String, completion: @escaping (Error?) -> Void)Parameters
codeThe reset code.
newPasswordThe new password.
completionOptionally; a block which is invoked when the request finishes. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Resets the password given a code sent to the user outside of the app and a new password for the user.
Possible error codes:
AuthErrorCodeWeakPassword- Indicates an attempt to set a password that is considered too weak.AuthErrorCodeOperationNotAllowed- Indicates the administrator disabled sign in with the specified identity provider.AuthErrorCodeExpiredActionCode- Indicates the OOB code is expired.AuthErrorCodeInvalidActionCode- Indicates the OOB code is invalid.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) open func confirmPasswordReset(withCode code: String, newPassword: String) async throwsParameters
codeThe reset code.
newPasswordThe new password.
 - 
                  
                  
Checks the validity of an out of band code.
Declaration
Swift
@objc open func checkActionCode(_ code: String, completion: @escaping (ActionCodeInfo?, Error?) -> Void)Parameters
codeThe out of band code to check validity.
completionOptionally; a block which is invoked when the request finishes. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Checks the validity of an out of band code.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) open func checkActionCode(_ code: String) async throws -> ActionCodeInfoParameters
codeThe out of band code to check validity.
Return Value
An
ActionCodeInfo. - 
                  
                  
Checks the validity of a verify password reset code.
Declaration
Swift
@objc open func verifyPasswordResetCode(_ code: String, completion: @escaping (String?, Error?) -> Void)Parameters
codeThe password reset code to be verified.
completionOptionally; a block which is invoked when the request finishes. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Checks the validity of a verify password reset code.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) open func verifyPasswordResetCode(_ code: String) async throws -> StringParameters
codeThe password reset code to be verified.
Return Value
An email.
 - 
                  
                  
Applies out of band code.
This method will not work for out of band codes which require an additional parameter, such as password reset code.
Declaration
Swift
@objc open func applyActionCode(_ code: String, completion: @escaping (Error?) -> Void)Parameters
codeThe out of band code to be applied.
completionOptionally; a block which is invoked when the request finishes. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Applies out of band code.
This method will not work for out of band codes which require an additional parameter, such as password reset code.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) open func applyActionCode(_ code: String) async throwsParameters
codeThe out of band code to be applied.
 - 
                  
                  
Initiates a password reset for the given email address.
This method does not throw an error when there’s no user account with the given email address and Email Enumeration Protection is enabled.
Possible error codes:
AuthErrorCodeInvalidRecipientEmail- Indicates an invalid recipient email was sent in the request.AuthErrorCodeInvalidSender- Indicates an invalid sender email is set in the console for this action.AuthErrorCodeInvalidMessagePayload- Indicates an invalid email template for sending update email.
Declaration
Swift
@objc open func sendPasswordReset(withEmail email: String, completion: ((Error?) -> Void)? = nil)Parameters
emailThe email address of the user.
completionOptionally; a block which is invoked when the request finishes. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Initiates a password reset for the given email address and
ActionCodeSettingsobject.This method does not throw an error when there’s no user account with the given email address and Email Enumeration Protection is enabled.
Possible error codes:
AuthErrorCodeInvalidRecipientEmail- Indicates an invalid recipient email was sent in the request.AuthErrorCodeInvalidSender- Indicates an invalid sender email is set in the console for this action.AuthErrorCodeInvalidMessagePayload- Indicates an invalid email template for sending update email.AuthErrorCodeMissingIosBundleID- Indicates that the iOS bundle ID is missing whenhandleCodeInAppis set to true.AuthErrorCodeMissingAndroidPackageName- Indicates that the android package name is missing when theandroidInstallAppflag is set to true.AuthErrorCodeUnauthorizedDomain- Indicates that the domain specified in the continue URL is not allowlisted in the Firebase console.AuthErrorCodeInvalidContinueURI- Indicates that the domain specified in the continue URL is not valid.
Declaration
Swift
@objc open func sendPasswordReset(withEmail email: String, actionCodeSettings: ActionCodeSettings?, completion: ((Error?) -> Void)? = nil)Parameters
emailThe email address of the user.
actionCodeSettingsAn
ActionCodeSettingsobject containing settings related to handling action codes.completionOptionally; a block which is invoked when the request finishes. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Initiates a password reset for the given email address and
ActionCodeSettingsobject.This method does not throw an error when there’s no user account with the given email address and Email Enumeration Protection is enabled.
Possible error codes:
AuthErrorCodeInvalidRecipientEmail- Indicates an invalid recipient email was sent in the request.AuthErrorCodeInvalidSender- Indicates an invalid sender email is set in the console for this action.AuthErrorCodeInvalidMessagePayload- Indicates an invalid email template for sending update email.AuthErrorCodeMissingIosBundleID- Indicates that the iOS bundle ID is missing whenhandleCodeInAppis set to true.AuthErrorCodeMissingAndroidPackageName- Indicates that the android package name is missing when theandroidInstallAppflag is set to true.AuthErrorCodeUnauthorizedDomain- Indicates that the domain specified in the continue URL is not allowlisted in the Firebase console.AuthErrorCodeInvalidContinueURI- Indicates that the domain specified in the continue URL is not valid.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) open func sendPasswordReset(withEmail email: String, actionCodeSettings: ActionCodeSettings? = nil) async throwsParameters
emailThe email address of the user.
actionCodeSettingsAn
ActionCodeSettingsobject containing settings related to handling action codes. - 
                  
                  
Sends a sign in with email link to provided email address.
Declaration
Swift
@objc open func sendSignInLink(toEmail email: String, actionCodeSettings: ActionCodeSettings, completion: ((Error?) -> Void)? = nil)Parameters
emailThe email address of the user.
actionCodeSettingsAn
ActionCodeSettingsobject containing settings related to handling action codes.completionOptionally; a block which is invoked when the request finishes. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Sends a sign in with email link to provided email address.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) open func sendSignInLink(toEmail email: String, actionCodeSettings: ActionCodeSettings) async throwsParameters
emailThe email address of the user.
actionCodeSettingsAn
ActionCodeSettingsobject containing settings related to handling action codes. - 
                  
                  
Signs out the current user.
Possible error codes:
AuthErrorCodeKeychainError- Indicates an error occurred when accessing the keychain. TheNSLocalizedFailureReasonErrorKeyfield in theuserInfodictionary will contain more information about the error encountered.
Declaration
Swift
@objc(signOut:) open func signOut() throws - 
                  
                  
Checks if link is an email sign-in link.
Declaration
Swift
@objc open func isSignIn(withEmailLink link: String) -> BoolParameters
linkThe email sign-in link.
Return Value
truewhen the link passed matches the expected format of an email sign-in link. - 
                  
                  
Initializes reCAPTCHA using the settings configured for the project or tenant.
If you change the tenant ID of the
Authinstance, the configuration will be reloaded. - 
                  
                  
Initializes reCAPTCHA using the settings configured for the project or tenant.
If you change the tenant ID of the
Authinstance, the configuration will be reloaded. - 
                  
                  
Registers a block as an “auth state did change” listener.
To be invoked when:
- The block is registered as a listener,
 - A user with a different UID from the current user has signed in, or
 - The current user has signed out.
 
The block is invoked immediately after adding it according to its standard invocation semantics, asynchronously on the main thread. Users should pay special attention to making sure the block does not inadvertently retain objects which should not be retained by the long-lived block. The block itself will be retained by
Authuntil it is unregistered or until theAuthinstance is otherwise deallocated.Declaration
Swift
@objc(addAuthStateDidChangeListener:) open func addStateDidChangeListener(_ listener: @escaping (Auth, User?) -> Void) -> NSObjectProtocolParameters
listenerThe block to be invoked. The block is always invoked asynchronously on the main thread, even for it’s initial invocation after having been added as a listener.
Return Value
A handle useful for manually unregistering the block as a listener.
 - 
                  
                  
Unregisters a block as an “auth state did change” listener.
Declaration
Swift
@objc(removeAuthStateDidChangeListener:) open func removeStateDidChangeListener(_ listenerHandle: NSObjectProtocol)Parameters
listenerHandleThe handle for the listener.
 - 
                  
                  
Registers a block as an “ID token did change” listener.
To be invoked when:
- The block is registered as a listener,
 - A user with a different UID from the current user has signed in,
 - The ID token of the current user has been refreshed, or
 - The current user has signed out.
 
The block is invoked immediately after adding it according to its standard invocation semantics, asynchronously on the main thread. Users should pay special attention to making sure the block does not inadvertently retain objects which should not be retained by the long-lived block. The block itself will be retained by
Authuntil it is unregistered or until theAuthinstance is otherwise deallocated.Declaration
Swift
@objc open func addIDTokenDidChangeListener(_ listener: @escaping (Auth, User?) -> Void) -> NSObjectProtocolParameters
listenerThe block to be invoked. The block is always invoked asynchronously on the main thread, even for it’s initial invocation after having been added as a listener.
Return Value
A handle useful for manually unregistering the block as a listener.
 - 
                  
                  
Unregisters a block as an “ID token did change” listener.
Declaration
Swift
@objc open func removeIDTokenDidChangeListener(_ listenerHandle: NSObjectProtocol)Parameters
listenerHandleThe handle for the listener.
 - 
                  
                  
Sets
languageCodeto the app’s current language.Declaration
Swift
@objc open func useAppLanguage() - 
                  
                  
Configures Firebase Auth to connect to an emulated host instead of the remote backend.
Declaration
Swift
@objc open func useEmulator(withHost host: String, port: Int) - 
                  
                  
Revoke the users token with authorization code.
Declaration
Swift
@objc open func revokeToken(withAuthorizationCode authorizationCode: String, completion: ((Error?) -> Void)? = nil)Parameters
authorizationCodeThe authorization code used to perform the revocation.
completion(Optional) the block invoked when the request to revoke the token is complete, or fails. Invoked asynchronously on the main thread in the future.
 - 
                  
                  
Revoke the users token with authorization code.
Declaration
Swift
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *) open func revokeToken(withAuthorizationCode authorizationCode: String) async throwsParameters
authorizationCodeThe authorization code used to perform the revocation.
 - 
                  
                  
Switch userAccessGroup and current user to the given accessGroup and the user stored in it.
Declaration
Swift
@objc open func useUserAccessGroup(_ accessGroup: String?) throws - 
                  
                  
Get the stored user in the given accessGroup.
This API is not supported on tvOS when
shareAuthStateAcrossDevicesis set totrue. and will returnnil.Please refer to https://github.com/firebase/firebase-ios-sdk/issues/8878 for details.
Declaration
Swift
open func getStoredUser(forAccessGroup accessGroup: String?) throws -> User? - 
                  
                  
The APNs token used for phone number authentication.
The type of the token (production or sandbox) will be automatically detected based on your provisioning profile.
This property is available on iOS only.
If swizzling is disabled, the APNs Token must be set for phone number auth to work, by either setting this property or by calling
setAPNSToken(_:type:).Declaration
Swift
@objc(APNSToken) open var apnsToken: Data? { get } - 
                  
                  
Sets the APNs token along with its type.
This method is available on iOS only.
If swizzling is disabled, the APNs Token must be set for phone number auth to work, by either setting calling this method or by setting the
APNSTokenproperty.Declaration
Swift
@objc open func setAPNSToken(_ token: Data, type: AuthAPNSTokenType) - 
                  
                  
Whether the specific remote notification is handled by
Auth.This method is available on iOS only.
If swizzling is disabled, related remote notifications must be forwarded to this method for phone number auth to work.
Declaration
Swift
@objc open func canHandleNotification(_ userInfo: [AnyHashable : Any]) -> BoolParameters
userInfoA dictionary that contains information related to the notification in question.
Return Value
Whether or the notification is handled. A return value of
truemeans the notification is for Firebase Auth so the caller should ignore the notification from further processing, andfalsemeans the notification is for the app (or another library) so the caller should continue handling this notification as usual. - 
                  
                  
Whether the specific URL is handled by
Auth.This method is available on iOS only.
If swizzling is disabled, URLs received by the application delegate must be forwarded to this method for phone number auth to work.
Declaration
Swift
@objc(canHandleURL:) open func canHandle(_ url: URL) -> BoolParameters
urlThe URL received by the application delegate from any of the openURL method.
Return Value
Whether or the URL is handled.
truemeans the URL is for Firebase Auth so the caller should ignore the URL from further processing, andfalsemeans the the URL is for the app (or another library) so the caller should continue handling this URL as usual. - 
                  
                  
The name of the
NSNotificationCenternotification which is posted when the auth state changes (for example, a new token has been produced, a user signs in or signs out).The object parameter of the notification is the sender
Authinstance.Declaration
Swift
public static let authStateDidChangeNotification: NSNotification.Name 
- 
                  
                  
Allow tests to swap in an alternate mainBundle, including ObjC unit tests via CocoaPods.
 - 
                  
                  
Undocumented
Declaration
Swift
@MainActor open func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) - 
                  
                  
Undocumented
Declaration
Swift
@MainActor open func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) - 
                  
                  
Undocumented
Declaration
Swift
@MainActor open func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) - 
                  
                  
Undocumented
Declaration
Swift
@MainActor open func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) - 
                  
                  
Undocumented
Declaration
Swift
@MainActor open func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool - 
                  
                  
Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
This method is not for public use. It is for Firebase clients of AuthInterop.
Declaration
Swift
@objc(getTokenForcingRefresh:withCallback:) public func getToken(forcingRefresh forceRefresh: Bool, completion callback: @escaping (String?, Error?) -> Void) - 
                  
                  
Get the current Auth user’s UID. Returns nil if there is no user signed in.
This method is not for public use. It is for Firebase clients of AuthInterop.
Declaration
Swift
open func getUserID() -> String?