registerWithEmailAndPassword

abstract suspend fun registerWithEmailAndPassword(name: String, email: String, password: String, activity: Activity): AuthUser

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

  1. Creates user account in Firebase Authentication

  2. Updates the user profile with the provided display name

  3. Saves credentials to Android Credential Manager

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

  • FirebaseAuthWeakPasswordException - Password doesn't meet requirements

  • FirebaseAuthInvalidCredentialsException - Email format is invalid

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

name

The user's display name (will be set in Firebase user profile)

email

The user's email address

password

The user's password (must meet Firebase security requirements)

activity

The activity instance required for saving credentials

Throws

FirebaseAuthException

for authentication/registration failures