registerWithGoogle

abstract suspend fun registerWithGoogle(activity: Activity): AuthUser

Registers a new user with their Google account using Google Sign-In.

This method is functionally identical to signInWithGoogle as Firebase automatically creates a new user account if the Google account hasn't been used before. The separation exists to provide semantic clarity in the UI (showing "Register" vs "Sign In" flows).

Process

  1. Shows Google account picker UI

  2. User selects a Google account

  3. Retrieves Google ID token

  4. Authenticates/creates account with Firebase using the Google credential

  5. Returns the authenticated user

Requirements

Exceptions

Example

// In your registration ViewModel
fun registerWithGoogle() {
_uiState.updateStateWith {
authRepository.registerWithGoogle(activity)
}
}

Return

The authenticated AuthUser upon successful registration/sign-in

Parameters

activity

The activity instance required for showing the Google Sign-In UI

See also

Throws

CancellationException

if user cancels the operation

for Google Sign-In or Firebase authentication failures