FirebaseAuth Framework Reference

FIRAuth


@interface FIRAuth : NSObject

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

    Objective-C

    + (nonnull FIRAuth *)auth;
  • Gets the auth object for a FirebaseApp.

    Declaration

    Objective-C

    + (nonnull FIRAuth *)authWithApp:(nonnull FIRApp *)app;

    Parameters

    app

    The app for which to retrieve the associated Auth instance.

    Return Value

    The Auth instance associated with the given app.

  • app

    Gets the FirebaseApp object that this auth object is connected to.

    Declaration

    Objective-C

    @property (nonatomic, weak, readonly, nullable) FIRApp *app;
  • Synchronously gets the cached current user, or null if there is none.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) FIRUser *currentUser;
  • 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

    Objective-C

    @property (nonatomic, copy, nullable) NSString *languageCode;
  • Contains settings related to the auth object.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) FIRAuthSettings *settings;
  • The current user access group that the Auth instance is using. Default is nil.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly, nullable) NSString *userAccessGroup;
  • Contains shareAuthStateAcrossDevices setting related to the auth object. If userAccessGroup is not set, setting shareAuthStateAcrossDevices will have no effect. You should set shareAuthStateAcrossDevices to it’s desired state and then set the userAccessGroup after.

    Declaration

    Objective-C

    @property (nonatomic) BOOL shareAuthStateAcrossDevices;
  • The tenant ID of the auth instance. nil if none is available.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSString *tenantID;
  • 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

    Objective-C

    @property (nonatomic, strong, nullable) NSData *APNSToken;
  • 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

    Objective-C

    @property (nonatomic, copy, nullable) NSString *customAuthDomain;
  • Please access auth instances using Auth.auth() and Auth.auth(app:).

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Sets the currentUser on the receiver to the provided user object.

    Declaration

    Objective-C

    - (void)updateCurrentUser:(nonnull FIRUser *)user
                   completion:(nullable void (^)(NSError *_Nullable))completion;

    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.

  • [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.
    

    See AuthErrors for a list of error codes that are common to all API methods.

    Declaration

    Objective-C

    - (void)fetchSignInMethodsForEmail:(nonnull NSString *)email
                            completion:
                                (nullable void (^)(NSArray<NSString *> *_Nullable,
                                                   NSError *_Nullable))completion;

    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 methods for the specified email address is ready or an error was encountered. Invoked asynchronously on the main thread in the future.

  • Signs in using an email address and password. When Email Enumeration Protection is enabled, this method fails with FIRAuthErrorCodeInvalidCredentials 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.
    

    See AuthErrors for a list of error codes that are common to all API methods.

    Declaration

    Objective-C

    - (void)signInWithEmail:(nonnull NSString *)email
                   password:(nonnull NSString *)password
                 completion:(nullable void (^)(FIRAuthDataResult *_Nullable,
                                               NSError *_Nullable))completion;

    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 email sign-in link.

    Possible error codes:

    + `AuthErrorCodeOperationNotAllowed` - Indicates that email and email sign-in link
        accounts are not enabled. Enable them in the Auth section of the
        Firebase console.
    + `AuthErrorCodeUserDisabled` - Indicates the user's account is disabled.
    + `AuthErrorCodeInvalidEmail` - Indicates the email address is invalid.
    

    See AuthErrors for a list of error codes that are common to all API methods.

    Declaration

    Objective-C

    - (void)signInWithEmail:(nonnull NSString *)email
                       link:(nonnull NSString *)link
                 completion:(nullable void (^)(FIRAuthDataResult *_Nullable,
                                               NSError *_Nullable))completion;

    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 the provided auth provider instance. This method is available on iOS, macOS Catalyst, and tvOS only.

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

    See AuthErrors for a list of error codes that are common to all API methods.

    Declaration

    Objective-C

    - (void)signInWithProvider:(nonnull id<FIRFederatedAuthProvider>)provider
                    UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
                    completion:(nullable void (^)(FIRAuthDataResult *_Nullable,
                                                  NSError *_Nullable))completion;

    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 AuthUIDelegate protocol, this is used for presenting the web context. If nil, a default AuthUIDelegate will 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.

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

    See AuthErrors for a list of error codes that are common to all API methods

    Declaration

    Objective-C

    - (void)signInWithCredential:(nonnull FIRAuthCredential *)credential
                      completion:(nullable void (^)(FIRAuthDataResult *_Nullable,
                                                    NSError *_Nullable))completion;

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

    See AuthErrors for a list of error codes that are common to all API methods.

    Declaration

    Objective-C

    - (void)signInAnonymouslyWithCompletion:
        (nullable void (^)(FIRAuthDataResult *_Nullable,
                           NSError *_Nullable))completion;

    Parameters

    completion

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

    See AuthErrors for a list of error codes that are common to all API methods.

    Declaration

    Objective-C

    - (void)signInWithCustomToken:(nonnull NSString *)token
                       completion:(nullable void (^)(FIRAuthDataResult *_Nullable,
                                                     NSError *_Nullable))completion;

    Parameters

    token

    A self-signed custom auth token.

    completion

    Optionally; a block which is invoked when the sign in 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.
    

    See AuthErrors for a list of error codes that are common to all API methods.

    Declaration

    Objective-C

    - (void)createUserWithEmail:(nonnull NSString *)email
                       password:(nonnull NSString *)password
                     completion:(nullable void (^)(FIRAuthDataResult *_Nullable,
                                                   NSError *_Nullable))completion;

    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.

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

    See AuthErrors for a list of error codes that are common to all API methods.

    Declaration

    Objective-C

    - (void)confirmPasswordResetWithCode:(nonnull NSString *)code
                             newPassword:(nonnull NSString *)newPassword
                              completion:
                                  (nonnull void (^)(NSError *_Nullable))completion;

    Parameters

    newPassword

    The new password.

    completion

    Optionally; 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

    Objective-C

    - (void)checkActionCode:(nonnull NSString *)code
                 completion:(nonnull void (^)(FIRActionCodeInfo *_Nullable,
                                              NSError *_Nullable))completion;

    Parameters

    code

    The out of band code to check validity.

    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

    Objective-C

    - (void)verifyPasswordResetCode:(nonnull NSString *)code
                         completion:
                             (nonnull void (^)(NSString *_Nullable,
                                               NSError *_Nullable))completion;

    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.

  • 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

    Objective-C

    - (void)applyActionCode:(nonnull NSString *)code
                 completion:(nonnull void (^)(NSError *_Nullable))completion;

    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.

  • 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

    Objective-C

    - (void)sendPasswordResetWithEmail:(nonnull NSString *)email
                            completion:
                                (nullable void (^)(NSError *_Nullable))completion;

    Parameters

    email

    The email address of the user.

    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 and ActionCodeSettings object.

    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 when
        `handleCodeInApp` is set to true.
    + `AuthErrorCodeMissingAndroidPackageName` - Indicates that the android package name
        is missing when the `androidInstallApp` flag 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

    Objective-C

    - (void)sendPasswordResetWithEmail:(nonnull NSString *)email
                    actionCodeSettings:
                        (nonnull FIRActionCodeSettings *)actionCodeSettings
                            completion:
                                (nullable void (^)(NSError *_Nullable))completion;

    Parameters

    email

    The email address of the user.

    actionCodeSettings

    An ActionCodeSettings object containing settings related to handling 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

    Objective-C

    - (void)sendSignInLinkToEmail:(nonnull NSString *)email
               actionCodeSettings:
                   (nonnull FIRActionCodeSettings *)actionCodeSettings
                       completion:(nullable void (^)(NSError *_Nullable))completion;

    Parameters

    email

    The email address of the user.

    actionCodeSettings

    An ActionCodeSettings object containing settings related to handling action codes.

    completion

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

  • Signs out the current user.

    Possible error codes:

    + `AuthErrorCodeKeychainError` - Indicates an error occurred when accessing the
        keychain. The `NSLocalizedFailureReasonErrorKey` field in the `userInfo`
        dictionary will contain more information about the error encountered.
    

    Declaration

    Objective-C

    - (BOOL)signOut:(NSError *_Nullable *_Nullable)error;

    Parameters

    error

    Optionally; if an error occurs, upon return contains an NSError object that describes the problem; is nil otherwise.

    Return Value

    @YES when the sign out request was successful. @NO otherwise.

  • Checks if link is an email sign-in link.

    Declaration

    Objective-C

    - (BOOL)isSignInWithEmailLink:(nonnull NSString *)link;

    Parameters

    link

    The email sign-in link.

    Return Value

    Returns true when the link passed matches the expected format of an email sign-in link.

  • 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 it’s 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 Auth until it is unregistered or until the Auth instance is otherwise deallocated.

    Declaration

    Objective-C

    - (nonnull FIRAuthStateDidChangeListenerHandle)addAuthStateDidChangeListener:
        (nonnull void (^)(FIRAuth *_Nonnull, FIRUser *_Nullable))listener;

    Parameters

    listener

    The 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

    Objective-C

    - (void)removeAuthStateDidChangeListener:
        (nonnull FIRAuthStateDidChangeListenerHandle)listenerHandle;

    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 it’s 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 Auth until it is unregistered or until the Auth instance is otherwise deallocated.

    Declaration

    Objective-C

    - (nonnull FIRIDTokenDidChangeListenerHandle)addIDTokenDidChangeListener:
        (nonnull void (^)(FIRAuth *_Nonnull, FIRUser *_Nullable))listener;

    Parameters

    listener

    The 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

    Objective-C

    - (void)removeIDTokenDidChangeListener:
        (nonnull FIRIDTokenDidChangeListenerHandle)listenerHandle;

    Parameters

    listenerHandle

    The handle for the listener.

  • Sets languageCode to the app’s current language.

    Declaration

    Objective-C

    - (void)useAppLanguage;
  • Configures Firebase Auth to connect to an emulated host instead of the remote backend.

    Declaration

    Objective-C

    - (void)useEmulatorWithHost:(nonnull NSString *)host port:(NSInteger)port;
  • Whether the specific URL is handled by Auth . This method is available on iOS only.

    Declaration

    Objective-C

    - (BOOL)canHandleURL:(nonnull NSURL *)URL;

    Parameters

    URL

    The URL received by the application delegate from any of the openURL method.

    Return Value

    Whether or the URL is handled. YES means the URL is for Firebase Auth so the caller should ignore the URL from further processing, and NO means the the URL is for the app (or another library) so the caller should continue handling this URL as usual. If swizzling is disabled, URLs received by the application delegate must be forwarded to this method for phone number auth to work.

  • 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 APNSToken property.

    Declaration

    Objective-C

    - (void)setAPNSToken:(nonnull NSData *)token type:(FIRAuthAPNSTokenType)type;
  • Whether the specific remote notification is handled by Auth . This method is available on iOS only.

    Declaration

    Objective-C

    - (BOOL)canHandleNotification:(nonnull NSDictionary *)userInfo;

    Parameters

    userInfo

    A dictionary that contains information related to the notification in question.

    Return Value

    Whether or the notification is handled. A return value of true means the notification is for Firebase Auth so the caller should ignore the notification from further processing, and false means the notification is for the app (or another library) so the caller should continue handling this notification as usual. If swizzling is disabled, related remote notifications must be forwarded to this method for phone number auth to work.

  • Revoke the users token with authorization code.

    Declaration

    Objective-C

    - (void)revokeTokenWithAuthorizationCode:(nonnull NSString *)authorizationCode
                                  completion:(nullable void (^)(NSError *_Nullable))
                                                 completion;

    Parameters

    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.

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

    If you change the tenant ID of the Auth instance, the configuration will be reloaded.

    Declaration

    Objective-C

    - (void)initializeRecaptchaConfigWithCompletion:
        (nullable void (^)(NSError *_Nullable))completion;
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy