registerWithEmailAndPassword
Registers a new user with email and password, then saves credentials to Credential Manager.
This method creates a new user account in Firebase Authentication using the provided email and password, sets the user's display name, and automatically saves the credentials to Android's Credential Manager for future one-tap sign-in.
Process
Creates user account in Firebase Authentication
Updates the user profile with the provided display name
Saves credentials to Android Credential Manager
Returns the authenticated user
Requirements
Email must be a valid, unused email address
Password must meet minimum security requirements (typically 6+ characters)
Requires an Activity context for saving credentials
Network connectivity is required
Exceptions
FirebaseAuthUserCollisionException- Email is already registeredFirebaseAuthWeakPasswordException- Password doesn't meet requirementsFirebaseAuthInvalidCredentialsException- Email format is invalidFirebaseNetworkException- Network connectivity issues
Example
// In your registration ViewModel
fun register(name: String, email: String, password: String) {
_uiState.updateStateWith {
authRepository.register(name, email, password, activity)
}
}Return
The authenticated AuthUser upon successful registration
Parameters
The user's display name (will be set in Firebase user profile)
The user's email address
The user's password (must meet Firebase security requirements)
The activity instance required for saving credentials
Throws
for authentication/registration failures