FirebaseAuth Framework Reference

Auth

@available(iOS13,tvOS13,macOS10.15,watchOS7,*)@preconcurrency@objc(FIRAuth)openclassAuth:NSObject
extensionAuth:UISceneDelegate
extensionAuth:UIApplicationDelegate
extensionAuth:AuthInterop

Manages 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

    @objcopenclassfuncauth()->Auth
  • Gets the auth object for aFirebaseApp.

    Declaration

    Swift

    @objcopenclassfuncauth(app:FirebaseApp)->Auth

    Parameters

    app

    The app for which to retrieve the associatedAuth instance.

    Return Value

    TheAuth instance associated with the given app.

  • Gets theFirebaseApp object that this auth object is connected to.

    Declaration

    Swift

    @objcpublicinternal(set)weakvarapp:FirebaseApp?{get}
  • Synchronously gets the cached current user, or null if there is none.

    Declaration

    Swift

    @objcpublicvarcurrentUser:User?{get}
  • The current user language code.

    This property can be set to the app’s current language bycallinguseAppLanguage().

    The string used to set this property must be a language code that follows BCP 47.

    Declaration

    Swift

    @objcopenvarlanguageCode:String?{getset}
  • Contains settings related to the auth object.

    Declaration

    Swift

    @NSCopying@objcopenvarsettings:AuthSettings?
  • The current user access group that the Auth instance is using.

    Default isnil.

    Declaration

    Swift

    @objcpublicinternal(set)varuserAccessGroup:String?{get}
  • Contains shareAuthStateAcrossDevices setting related to the auth object.

    If userAccessGroup is not set, setting shareAuthStateAcrossDevices willhave no effect. You should set shareAuthStateAcrossDevices to its desiredstate and then set the userAccessGroup after.

    Declaration

    Swift

    @objcopenvarshareAuthStateAcrossDevices:Bool
  • The tenant ID of the auth instance.nil if none is available.

    Declaration

    Swift

    @objcopenvartenantID:String?
  • The custom authentication domain used to handle all sign-in redirects.End-users will seethis domain when signing in. This domain must be allowlisted in the Firebase Console.

    Declaration

    Swift

    @objcopenvarcustomAuthDomain:String?
  • Sets thecurrentUser on the receiver to the provided user object.

    Declaration

    Swift

    @objcopenfuncupdateCurrentUser(_user:User?,completion:((Error?)->Void)?=nil)

    Parameters

    user

    The user object to be set as the current user of the calling Auth instance.

    completion

    Optionally; a block invoked after the user of the calling Auth instance has been updated or an error was encountered.

  • Sets thecurrentUser on the receiver to the provided user object.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)openfuncupdateCurrentUser(_user:User)asyncthrows

    Parameters

    user

    The 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 providedemail address. This method returns an empty list whenEmail EnumerationProtectionis enabled, irrespective of the number of authentication methods available for the givenemail.

    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.")@objcopenfuncfetchSignInMethods(forEmailemail:String,completion:(([String]?,Error?)->Void)?=nil)

    Parameters

    email

    The email address for which to obtain a list of sign-in methods.

    completion

    Optionally; a block which is invoked when the list of sign in methodsfor the specified email address is ready or an error was encountered. Invoked asynchronouslyon the main thread in the future.

  • [Deprecated] Fetches the list of all sign-in methods previously used for the providedemail address. This method returns an empty list whenEmail EnumerationProtectionis enabled, irrespective of the number of authentication methods available for the givenemail.

    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.")openfuncfetchSignInMethods(forEmailemail:String)asyncthrows->[String]

    Parameters

    email

    The 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.

    WhenEmail EnumerationProtectionis enabled, this method fails with an error in case of an invalidemail/password.

    Possible error codes:

    • AuthErrorCodeOperationNotAllowed - Indicates that email and passwordaccounts are not enabled. Enable them in the Auth section of theFirebase console.
      • AuthErrorCodeUserDisabled - Indicates the user’s account is disabled.
      • AuthErrorCodeWrongPassword - Indicates the user attemptedsign in with an incorrect password.
      • AuthErrorCodeInvalidEmail - Indicates the email address is malformed.

    Declaration

    Swift

    @objcopenfuncsignIn(withEmailemail:String,password:String,completion:((AuthDataResult?,Error?)->Void)?=nil)

    Parameters

    email

    The user’s email address.

    password

    The user’s password.

    completion

    Optionally; 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 passwordaccounts are not enabled. Enable them in the Auth section of theFirebase console.
      • AuthErrorCodeUserDisabled - Indicates the user’s account is disabled.
      • AuthErrorCodeWrongPassword - Indicates the user attemptedsign in with an incorrect password.
      • AuthErrorCodeInvalidEmail - Indicates the email address is malformed.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)@discardableResultopenfuncsignIn(withEmailemail:String,password:String)asyncthrows->AuthDataResult

    Parameters

    email

    The user’s email address.

    password

    The user’s password.

    Return Value

    TheAuthDataResult after a successful signin.

  • Signs in using an email address and email sign-in link.

    Possible error codes:

    • AuthErrorCodeOperationNotAllowed - Indicates that email and passwordaccounts are not enabled. Enable them in the Auth section of theFirebase console.
      • AuthErrorCodeUserDisabled - Indicates the user’s account is disabled.
      • AuthErrorCodeWrongPassword - Indicates the user attemptedsign in with an incorrect password.
      • AuthErrorCodeInvalidEmail - Indicates the email address is malformed.

    Declaration

    Swift

    @objcopenfuncsignIn(withEmailemail:String,link:String,completion:((AuthDataResult?,Error?)->Void)?=nil)

    Parameters

    email

    The user’s email address.

    link

    The email sign-in link.

    completion

    Optionally; 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 passwordaccounts are not enabled. Enable them in the Auth section of theFirebase console.
      • AuthErrorCodeUserDisabled - Indicates the user’s account is disabled.
      • AuthErrorCodeWrongPassword - Indicates the user attemptedsign in with an incorrect password.
      • AuthErrorCodeInvalidEmail - Indicates the email address is malformed.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)openfuncsignIn(withEmailemail:String,link:String)asyncthrows->AuthDataResult

    Parameters

    email

    The user’s email address.

    link

    The email sign-in link.

    Return Value

    TheAuthDataResult after a successful signin.

  • Signs in using the provided auth provider instance.

    Possible error codes:

    • AuthErrorCodeOperationNotAllowed - Indicates that email and passwordaccounts are not enabled. Enable them in the Auth section of theFirebase console.
      • AuthErrorCodeUserDisabled - Indicates the user’s account is disabled.
      • AuthErrorCodeWrongPassword - Indicates the user attemptedsign in with an incorrect password.
      • AuthErrorCodeWebNetworkRequestFailed - Indicates that a network request within aSFSafariViewController or WKWebView failed.
      • AuthErrorCodeWebInternalError - Indicates that an internal error occurred within aSFSafariViewController or WKWebView.
      • AuthErrorCodeWebSignInUserInteractionFailure - Indicates a general failure duringa web sign-in flow.
      • AuthErrorCodeWebContextAlreadyPresented - Indicates that an attempt was made topresent a new web context while one was already being presented.
      • AuthErrorCodeWebContextCancelled - Indicates that the URL presentation wascancelled prematurely by the user.
      • AuthErrorCodeAccountExistsWithDifferentCredential - Indicates the email assertedby the credential (e.g. the email in a Facebook access token) is already in use by anexisting account, that cannot be authenticated with this sign-in method. CallfetchProvidersForEmail for this user’s email and then prompt them to sign in with any ofthe sign-in providers returned. This error will only be thrown if the “One account peremail 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:)openfuncsignIn(withprovider:FederatedAuthProvider,uiDelegate:AuthUIDelegate?,completion:((AuthDataResult?,Error?)->Void)?)

    Parameters

    provider

    An instance of an auth provider used to initiate the sign-in flow.

    uiDelegate

    Optionally an instance of a class conforming to the AuthUIDelegateprotocol, this is used for presenting the web context. If nil, a default AuthUIDelegatewill be used.

    completion

    Optionally; 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 passwordaccounts are not enabled. Enable them in the Auth section of theFirebase console.
      • AuthErrorCodeUserDisabled - Indicates the user’s account is disabled.
      • AuthErrorCodeWrongPassword - Indicates the user attemptedsign in with an incorrect password.
      • AuthErrorCodeWebNetworkRequestFailed - Indicates that a network request within aSFSafariViewController or WKWebView failed.
      • AuthErrorCodeWebInternalError - Indicates that an internal error occurred within aSFSafariViewController or WKWebView.
      • AuthErrorCodeWebSignInUserInteractionFailure - Indicates a general failure duringa web sign-in flow.
      • AuthErrorCodeWebContextAlreadyPresented - Indicates that an attempt was made topresent a new web context while one was already being presented.
      • AuthErrorCodeWebContextCancelled - Indicates that the URL presentation wascancelled prematurely by the user.
      • AuthErrorCodeAccountExistsWithDifferentCredential - Indicates the email assertedby the credential (e.g. the email in a Facebook access token) is already in use by anexisting account, that cannot be authenticated with this sign-in method. CallfetchProvidersForEmail for this user’s email and then prompt them to sign in with any ofthe sign-in providers returned. This error will only be thrown if the “One account peremail address” setting is enabled in the Firebase console, under Auth settings.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)@available(tvOS,unavailable)@available(macOS,unavailable)@available(watchOS,unavailable)@discardableResultopenfuncsignIn(withprovider:FederatedAuthProvider,uiDelegate:AuthUIDelegate?)asyncthrows->AuthDataResult

    Parameters

    provider

    An instance of an auth provider used to initiate the sign-in flow.

    uiDelegate

    Optionally an instance of a class conforming to the AuthUIDelegateprotocol, this is used for presenting the web context. If nil, a default AuthUIDelegatewill be used.

    Return Value

    TheAuthDataResult after the successful signin.

  • Asynchronously signs in to Firebase with the given 3rd-party credentials (e.g. a Facebooklogin Access Token, a Google ID Token/Access Token pair, etc.) and returns additionalidentity 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 accountswith the identity provider represented by the credential are not enabled.Enable them in the Auth section of the Firebase console.
    • AuthErrorCodeAccountExistsWithDifferentCredential - Indicates the email assertedby the credential (e.g. the email in a Facebook access token) is already in use by anexisting account, that cannot be authenticated with this sign-in method. CallfetchProvidersForEmail for this user’s email and then prompt them to sign in with any ofthe sign-in providers returned. This error will only be thrown if the “One account peremail 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 anincorrect password, if credential is of the type EmailPasswordAuthCredential.
    • AuthErrorCodeInvalidEmail - Indicates the email address is malformed.
    • AuthErrorCodeMissingVerificationID - Indicates that the phone auth credential wascreated with an empty verification ID.
    • AuthErrorCodeMissingVerificationCode - Indicates that the phone auth credentialwas created with an empty verification code.
    • AuthErrorCodeInvalidVerificationCode - Indicates that the phone auth credentialwas created with an invalid verification Code.
    • AuthErrorCodeInvalidVerificationID - Indicates that the phone auth credential wascreated with an invalid verification ID.
    • AuthErrorCodeSessionExpired - Indicates that the SMS code has expired.

    Declaration

    Swift

    @objc(signInWithCredential:completion:)openfuncsignIn(withcredential:AuthCredential,completion:((AuthDataResult?,Error?)->Void)?=nil)

    Parameters

    credential

    The credential supplied by the IdP.

    completion

    Optionally; 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 Facebooklogin Access Token, a Google ID Token/Access Token pair, etc.) and returns additionalidentity 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 accountswith the identity provider represented by the credential are not enabled.Enable them in the Auth section of the Firebase console.
    • AuthErrorCodeAccountExistsWithDifferentCredential - Indicates the email assertedby the credential (e.g. the email in a Facebook access token) is already in use by anexisting account, that cannot be authenticated with this sign-in method. CallfetchProvidersForEmail for this user’s email and then prompt them to sign in with any ofthe sign-in providers returned. This error will only be thrown if the “One account peremail 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 anincorrect password, if credential is of the type EmailPasswordAuthCredential.
    • AuthErrorCodeInvalidEmail - Indicates the email address is malformed.
    • AuthErrorCodeMissingVerificationID - Indicates that the phone auth credential wascreated with an empty verification ID.
    • AuthErrorCodeMissingVerificationCode - Indicates that the phone auth credentialwas created with an empty verification code.
    • AuthErrorCodeInvalidVerificationCode - Indicates that the phone auth credentialwas created with an invalid verification Code.
    • AuthErrorCodeInvalidVerificationID - Indicates that the phone auth credential wascreated with an invalid verification ID.
    • AuthErrorCodeSessionExpired - Indicates that the SMS code has expired.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)@discardableResultopenfuncsignIn(withcredential:AuthCredential)asyncthrows->AuthDataResult

    Parameters

    credential

    The credential supplied by the IdP.

    Return Value

    TheAuthDataResult after 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 arenot enabled. Enable them in the Auth section of the Firebase console.

    Declaration

    Swift

    @objcopenfuncsignInAnonymously(completion:((AuthDataResult?,Error?)->Void)?=nil)

    Parameters

    completion

    Optionally; a block which is invoked when the sign in finishes, or iscanceled. 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 arenot enabled. Enable them in the Auth section of the Firebase console.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)@discardableResult@objcopenfuncsignInAnonymously()asyncthrows->AuthDataResult

    Return Value

    TheAuthDataResult after the successful signin.

  • Asynchronously signs in to Firebase with the given Auth token.

    Possible error codes:

    • AuthErrorCodeInvalidCustomToken - Indicates a validation error withthe custom token.
    • AuthErrorCodeCustomTokenMismatch - Indicates the service account and the API keybelong to different projects.

    Declaration

    Swift

    @objcopenfuncsignIn(withCustomTokentoken:String,completion:((AuthDataResult?,Error?)->Void)?=nil)

    Parameters

    token

    A self-signed custom auth token.

    completion

    Optionally; a block which is invoked when the sign in finishes, or iscanceled. 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 withthe custom token.
    • AuthErrorCodeCustomTokenMismatch - Indicates the service account and the API keybelong to different projects.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)@discardableResultopenfuncsignIn(withCustomTokentoken:String)asyncthrows->AuthDataResult

    Parameters

    token

    A self-signed custom auth token.

    Return Value

    TheAuthDataResult after 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 upalready exists. Call fetchProvidersForEmail to check which sign-in mechanisms the userused, and prompt the user to sign in with one of those.
    • AuthErrorCodeOperationNotAllowed - Indicates that email and password accountsare not enabled. Enable them in the Auth section of the Firebase console.
    • AuthErrorCodeWeakPassword - Indicates an attempt to set a password that isconsidered too weak. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfodictionary object will contain more detailed explanation that can be shown to the user.

    Declaration

    Swift

    @objcopenfunccreateUser(withEmailemail:String,password:String,completion:((AuthDataResult?,Error?)->Void)?=nil)

    Parameters

    email

    The user’s email address.

    password

    The user’s desired password.

    completion

    Optionally; 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 upalready exists. Call fetchProvidersForEmail to check which sign-in mechanisms the userused, and prompt the user to sign in with one of those.
    • AuthErrorCodeOperationNotAllowed - Indicates that email and password accountsare not enabled. Enable them in the Auth section of the Firebase console.
    • AuthErrorCodeWeakPassword - Indicates an attempt to set a password that isconsidered too weak. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfodictionary object will contain more detailed explanation that can be shown to the user.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)@discardableResultopenfunccreateUser(withEmailemail:String,password:String)asyncthrows->AuthDataResult

    Parameters

    email

    The user’s email address.

    password

    The user’s desired password.

    Return Value

    TheAuthDataResult after the successful signin.

  • Resets the password given a code sent to the user outside of the app and a new passwordfor the user.

    Possible error codes:

    • AuthErrorCodeWeakPassword - Indicates an attempt to set a password that isconsidered too weak.
    • AuthErrorCodeOperationNotAllowed - Indicates the administrator disabled signin with the specified identity provider.
    • AuthErrorCodeExpiredActionCode - Indicates the OOB code is expired.
    • AuthErrorCodeInvalidActionCode - Indicates the OOB code is invalid.

    Declaration

    Swift

    @objcopenfuncconfirmPasswordReset(withCodecode:String,newPassword:String,completion:@escaping(Error?)->Void)

    Parameters

    code

    The reset code.

    newPassword

    The new password.

    completion

    Optionally; 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 passwordfor the user.

    Possible error codes:

    • AuthErrorCodeWeakPassword - Indicates an attempt to set a password that isconsidered too weak.
    • AuthErrorCodeOperationNotAllowed - Indicates the administrator disabled signin with the specified identity provider.
    • AuthErrorCodeExpiredActionCode - Indicates the OOB code is expired.
    • AuthErrorCodeInvalidActionCode - Indicates the OOB code is invalid.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)openfuncconfirmPasswordReset(withCodecode:String,newPassword:String)asyncthrows

    Parameters

    code

    The reset code.

    newPassword

    The new password.

  • Checks the validity of an out of band code.

    Declaration

    Swift

    @objcopenfunccheckActionCode(_code:String,completion:@escaping(ActionCodeInfo?,Error?)->Void)

    Parameters

    code

    The out of band code to check validity.

    completion

    Optionally; a block which is invoked when the request finishes.Invokedasynchronously on the main thread in the future.

  • Checks the validity of an out of band code.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)openfunccheckActionCode(_code:String)asyncthrows->ActionCodeInfo

    Parameters

    code

    The out of band code to check validity.

    Return Value

    AnActionCodeInfo.

  • Checks the validity of a verify password reset code.

    Declaration

    Swift

    @objcopenfuncverifyPasswordResetCode(_code:String,completion:@escaping(String?,Error?)->Void)

    Parameters

    code

    The password reset code to be verified.

    completion

    Optionally; 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(iOS13,tvOS13,macOS10.15,watchOS7,*)openfuncverifyPasswordResetCode(_code:String)asyncthrows->String

    Parameters

    code

    The 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

    @objcopenfuncapplyActionCode(_code:String,completion:@escaping(Error?)->Void)

    Parameters

    code

    The out of band code to be applied.

    completion

    Optionally; 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(iOS13,tvOS13,macOS10.15,watchOS7,*)openfuncapplyActionCode(_code:String)asyncthrows

    Parameters

    code

    The out of band code to be applied.

  • Initiates a password reset for the given email address.

    This method does not throw anerror when there’s no user account with the given email address andEmail EnumerationProtectionis enabled.

    Possible error codes:

    • AuthErrorCodeInvalidRecipientEmail - Indicates an invalid recipient email wassent in the request.
    • AuthErrorCodeInvalidSender - Indicates an invalid sender email is set inthe console for this action.
    • AuthErrorCodeInvalidMessagePayload - Indicates an invalid email template forsending update email.

    Declaration

    Swift

    @objcopenfuncsendPasswordReset(withEmailemail:String,completion:((Error?)->Void)?=nil)

    Parameters

    email

    The email address of the user.

    completion

    Optionally; a block which is invoked when the request finishes.Invokedasynchronously on the main thread in the future.

  • Initiates a password reset for the given email address andActionCodeSettings object.

    This method does not throw anerror when there’s no user account with the given email address andEmail EnumerationProtectionis enabled.

    Possible error codes:

    • AuthErrorCodeInvalidRecipientEmail - Indicates an invalid recipient email wassent in the request.
    • AuthErrorCodeInvalidSender - Indicates an invalid sender email is set inthe console for this action.
    • AuthErrorCodeInvalidMessagePayload - Indicates an invalid email template forsending update email.
    • AuthErrorCodeMissingIosBundleID - Indicates that the iOS bundle ID is missing whenhandleCodeInApp is set to true.
    • AuthErrorCodeMissingAndroidPackageName - Indicates that the android package nameis missing when theandroidInstallApp flag is set to true.
    • AuthErrorCodeUnauthorizedDomain - Indicates that the domain specified in thecontinue URL is not allowlisted in the Firebase console.
    • AuthErrorCodeInvalidContinueURI - Indicates that the domain specified in thecontinue URL is not valid.

    Declaration

    Swift

    @objcopenfuncsendPasswordReset(withEmailemail:String,actionCodeSettings:ActionCodeSettings?,completion:((Error?)->Void)?=nil)

    Parameters

    email

    The email address of the user.

    actionCodeSettings

    AnActionCodeSettings object containing settings related tohandling action codes.

    completion

    Optionally; 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 andActionCodeSettings object.

    This method does not throw anerror when there’s no user account with the given email address andEmail EnumerationProtectionis enabled.

    Possible error codes:

    • AuthErrorCodeInvalidRecipientEmail - Indicates an invalid recipient email wassent in the request.
    • AuthErrorCodeInvalidSender - Indicates an invalid sender email is set inthe console for this action.
    • AuthErrorCodeInvalidMessagePayload - Indicates an invalid email template forsending update email.
    • AuthErrorCodeMissingIosBundleID - Indicates that the iOS bundle ID is missing whenhandleCodeInApp is set to true.
    • AuthErrorCodeMissingAndroidPackageName - Indicates that the android package nameis missing when theandroidInstallApp flag is set to true.
    • AuthErrorCodeUnauthorizedDomain - Indicates that the domain specified in thecontinue URL is not allowlisted in the Firebase console.
    • AuthErrorCodeInvalidContinueURI - Indicates that the domain specified in thecontinue URL is not valid.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)openfuncsendPasswordReset(withEmailemail:String,actionCodeSettings:ActionCodeSettings?=nil)asyncthrows

    Parameters

    email

    The email address of the user.

    actionCodeSettings

    AnActionCodeSettings object containing settings related tohandling action codes.

  • Sends a sign in with email link to provided email address.

    Declaration

    Swift

    @objcopenfuncsendSignInLink(toEmailemail:String,actionCodeSettings:ActionCodeSettings,completion:((Error?)->Void)?=nil)

    Parameters

    email

    The email address of the user.

    actionCodeSettings

    AnActionCodeSettings object containing settings related tohandling action codes.

    completion

    Optionally; 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(iOS13,tvOS13,macOS10.15,watchOS7,*)openfuncsendSignInLink(toEmailemail:String,actionCodeSettings:ActionCodeSettings)asyncthrows

    Parameters

    email

    The email address of the user.

    actionCodeSettings

    AnActionCodeSettings object containing settings related tohandling action codes.

  • Signs out the current user.

    Possible error codes:

    • AuthErrorCodeKeychainError - Indicates an error occurred when accessing thekeychain. TheNSLocalizedFailureReasonErrorKey field in theuserInfodictionary will contain more information about the error encountered.

    Declaration

    Swift

    @objc(signOut:)openfuncsignOut()throws
  • Checks if link is an email sign-in link.

    Declaration

    Swift

    @objcopenfuncisSignIn(withEmailLinklink:String)->Bool

    Parameters

    link

    The email sign-in link.

    Return Value

    true when 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 theAuth instance, the configuration will bereloaded.

  • Initializes reCAPTCHA using the settings configured for the project or tenant.

    If you change the tenant ID of theAuth instance, the configuration will bereloaded.

  • 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 invocationsemantics, asynchronously on the main thread. Users should pay special attention tomaking sure the block does not inadvertently retain objects which should not be retained bythe long-lived block. The block itself will be retained byAuth until it isunregistered or until theAuth instance is otherwise deallocated.

    Declaration

    Swift

    @objc(addAuthStateDidChangeListener:)openfuncaddStateDidChangeListener(_listener:@escaping(Auth,User?)->Void)->NSObjectProtocol

    Parameters

    listener

    The block to be invoked. The block is always invoked asynchronously onthe 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:)openfuncremoveStateDidChangeListener(_listenerHandle:NSObjectProtocol)

    Parameters

    listenerHandle

    The 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 invocationsemantics, asynchronously on the main thread. Users should pay special attention tomaking sure the block does not inadvertently retain objects which should not be retained bythe long-lived block. The block itself will be retained byAuth until it isunregistered or until theAuth instance is otherwise deallocated.

    Declaration

    Swift

    @objcopenfuncaddIDTokenDidChangeListener(_listener:@escaping(Auth,User?)->Void)->NSObjectProtocol

    Parameters

    listener

    The block to be invoked. The block is always invoked asynchronously onthe 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

    @objcopenfuncremoveIDTokenDidChangeListener(_listenerHandle:NSObjectProtocol)

    Parameters

    listenerHandle

    The handle for the listener.

  • SetslanguageCode to the app’s current language.

    Declaration

    Swift

    @objcopenfuncuseAppLanguage()
  • Configures Firebase Auth to connect to an emulated host instead of the remote backend.

    Declaration

    Swift

    @objcopenfuncuseEmulator(withHosthost:String,port:Int)
  • Revoke the users token with authorization code.

    Declaration

    Swift

    @objcopenfuncrevokeToken(withAuthorizationCodeauthorizationCode:String,completion:((Error?)->Void)?=nil)

    Parameters

    authorizationCode

    The authorization code used to perform the revocation.

    completion

    (Optional) the block invoked when the request to revoke the token iscomplete, or fails. Invoked asynchronously on the main thread in the future.

  • Revoke the users token with authorization code.

    Declaration

    Swift

    @available(iOS13,tvOS13,macOS10.15,watchOS7,*)openfuncrevokeToken(withAuthorizationCodeauthorizationCode:String)asyncthrows

    Parameters

    authorizationCode

    The authorization code used to perform the revocation.

  • Switch userAccessGroup and current user to the given accessGroup and the user stored in it.

    Declaration

    Swift

    @objcopenfuncuseUserAccessGroup(_accessGroup:String?)throws
  • Get the stored user in the given accessGroup.

    This API is not supported on tvOS whenshareAuthStateAcrossDevices is set totrue.and will returnnil.

    Please refer tohttps://github.com/firebase/firebase-ios-sdk/issues/8878 for details.

    Declaration

    Swift

    openfuncgetStoredUser(forAccessGroupaccessGroup:String?)throws->User?
  • The APNs token used for phone number authentication.

    The type of the token (production or sandbox) will be automaticallydetected 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 callingsetAPNSToken(_:type:).

    Declaration

    Swift

    @objc(APNSToken)openvarapnsToken: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 theAPNSToken property.

    Declaration

    Swift

    @objcopenfuncsetAPNSToken(_token:Data,type:AuthAPNSTokenType)
  • Whether the specific remote notification is handled byAuth .

    This method is available on iOS only.

    If swizzling is disabled, related remote notifications must be forwarded to this methodfor phone number auth to work.

    Declaration

    Swift

    @objcopenfunccanHandleNotification(_userInfo:[AnyHashable:Any])->Bool

    Parameters

    userInfo

    A dictionary that contains information related to thenotification in question.

    Return Value

    Whether or the notification is handled. A return value oftrue means thenotification is for Firebase Auth so the caller should ignore the notification from furtherprocessing, andfalse means the notification is for the app (or another library) sothe caller should continue handling this notification as usual.

  • Whether the specific URL is handled byAuth .

    This method is available on iOS only.

    If swizzling is disabled, URLs received by the application delegate must be forwardedto this method for phone number auth to work.

    Declaration

    Swift

    @objc(canHandleURL:)openfunccanHandle(_url:URL)->Bool

    Parameters

    url

    The URL received by the application delegate from any of the openURLmethod.

    Return Value

    Whether or the URL is handled.true means the URL is for Firebase Authso the caller should ignore the URL from further processing, andfalse means thethe URL is for the app (or another library) so the caller should continue handlingthis URL as usual.

  • The name of theNSNotificationCenter notification which is posted when the auth statechanges (for example, a new token has been produced, a user signs in or signs out).

    The object parameter of the notification is the senderAuth instance.

    Declaration

    Swift

    publicstaticletauthStateDidChangeNotification:NSNotification.Name
  • Allow tests to swap in an alternate mainBundle, including ObjC unit tests via CocoaPods.

  • Undocumented

    Declaration

    Swift

    @MainActoropenfuncscene(_scene:UIScene,openURLContextsURLContexts:Set<UIOpenURLContext>)
  • Undocumented

    Declaration

    Swift

    @MainActoropenfuncapplication(_application:UIApplication,didRegisterForRemoteNotificationsWithDeviceTokendeviceToken:Data)
  • Undocumented

    Declaration

    Swift

    @MainActoropenfuncapplication(_application:UIApplication,didFailToRegisterForRemoteNotificationsWithErrorerror:Error)
  • Undocumented

    Declaration

    Swift

    @MainActoropenfuncapplication(_application:UIApplication,didReceiveRemoteNotificationuserInfo:[AnyHashable:Any],fetchCompletionHandlercompletionHandler:@escaping(UIBackgroundFetchResult)->Void)
  • Undocumented

    Declaration

    Swift

    @MainActoropenfuncapplication(_application:UIApplication,openurl: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:)publicfuncgetToken(forcingRefreshforceRefresh:Bool,completioncallback:@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

    openfuncgetUserID()->String?

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-03-11 UTC.