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
FIRApp
.Declaration
Objective-C
+ (nonnull FIRAuth *)authWithApp:(nonnull FIRApp *)app;
Parameters
app
The FIRApp for which to retrieve the associated FIRAuth instance.
Return Value
The FIRAuth instance associated with the given FIRApp.
-
Gets the
FIRApp
object that this auth object is connected to.Declaration
Objective-C
@property (readonly, nonatomic, nullable) FIRApp *app;
-
Synchronously gets the cached current user, or null if there is none.
Declaration
Objective-C
@property (readonly, strong, nonatomic, 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 (readwrite, copy, nonatomic, nullable) NSString *languageCode;
-
Contains settings related to the auth object.
Declaration
Objective-C
@property (readwrite, copy, nonatomic, nullable) FIRAuthSettings *settings;
-
The current user access group that the Auth instance is using. Default is nil.
Declaration
Objective-C
@property (readonly, copy, nonatomic, nullable) NSString *userAccessGroup;
-
The APNs token used for phone number authentication. The type of the token (production or sandbox) will be attempted to be automatcially detected. 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 (readwrite, strong, nonatomic, nullable) NSData *APNSToken;
-
Please access auth instances using
FIRAuth.auth
andFIRAuth.authForApp:
.Declaration
Objective-C
- (nonnull instancetype)init;
-
Sets the currentUser on the calling Auth instance to the provided user object.
Declaration
Objective-C
- (void)updateCurrentUser:(nonnull FIRUser *)user completion:(nullable FIRUserUpdateCallback)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.
-
Please use fetchSignInMethodsForEmail:completion: for Objective-C or fetchSignInMethods(forEmail:completion:) for Swift instead.
Declaration
Objective-C
- (void)fetchProvidersForEmail:(nonnull NSString *)email completion:(nullable FIRProviderQueryCallback)completion;
-
Fetches the list of all sign-in methods previously used for the provided email address.
Possible error codes:
+ `FIRAuthErrorCodeInvalidEmail` - Indicates the email address is malformed.
See
FIRAuthErrors
for a list of error codes that are common to all API methods.Declaration
Objective-C
- (void)fetchSignInMethodsForEmail:(nonnull NSString *)email completion: (nullable FIRSignInMethodQueryCallback)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.
Possible error codes:
+ `FIRAuthErrorCodeOperationNotAllowed` - Indicates that email and password accounts are not enabled. Enable them in the Auth section of the Firebase console. + `FIRAuthErrorCodeUserDisabled` - Indicates the user's account is disabled. + `FIRAuthErrorCodeWrongPassword` - Indicates the user attempted sign in wi