Class AuthUI


  • public final class AuthUI
    extends Object
    The entry point to the AuthUI authentication flow, and related utility methods. If your application uses the default FirebaseApp instance, an AuthUI instance can be retrieved simply by calling getInstance(). If an alternative app instance is in use, call getInstance(FirebaseApp) instead, passing the appropriate app instance.

    See the README for examples on how to get started with FirebaseUI Auth.

    • Method Detail

      • getApplicationContext

        @NonNull
        public static Context getApplicationContext()
      • setApplicationContext

        public static void setApplicationContext​(@NonNull
                                                 Context context)
      • getInstance

        @NonNull
        public static AuthUI getInstance()
        Retrieves the AuthUI instance associated with the default app, as returned by FirebaseApp.getInstance().
        Throws:
        IllegalStateException - if the default app is not initialized.
      • getInstance

        @NonNull
        public static AuthUI getInstance​(@NonNull
                                         String appName)
        Retrieves the AuthUI instance associated the the specified app name.
        Throws:
        IllegalStateException - if the app is not initialized.
      • getInstance

        @NonNull
        public static AuthUI getInstance​(@NonNull
                                         com.google.firebase.FirebaseApp app)
        Retrieves the AuthUI instance associated the the specified app.
      • getApp

        @NonNull
        public com.google.firebase.FirebaseApp getApp()
      • getAuth

        @NonNull
        public com.google.firebase.auth.FirebaseAuth getAuth()
      • canHandleIntent

        public static boolean canHandleIntent​(@NonNull
                                              Intent intent)
        Returns true if AuthUI can handle the intent.

        AuthUI handle the intent when the embedded data is an email link. If it is, you can then specify the link in AuthUI.SignInIntentBuilder.setEmailLink(String) before starting AuthUI and it will be handled immediately.

      • getDefaultTheme

        @StyleRes
        public static int getDefaultTheme()
        Default theme used by AuthUI.AuthIntentBuilder.setTheme(int) if no theme customization is required.
      • silentSignIn

        @NonNull
        public com.google.android.gms.tasks.Task<com.google.firebase.auth.AuthResult> silentSignIn​(@NonNull
                                                                                                   Context context,
                                                                                                   @NonNull
                                                                                                   List<AuthUI.IdpConfig> configs)
        Signs the user in without any UI if possible. If this operation fails, you can safely start a UI-based sign-in flow knowing it is required.
        Parameters:
        context - requesting the user be signed in
        configs - to use for silent sign in. Only Google and email are currently supported, the rest will be ignored.
        Returns:
        a task which indicates whether or not the user was successfully signed in.
      • signOut

        @NonNull
        public com.google.android.gms.tasks.Task<Void> signOut​(@NonNull
                                                               Context context)
        Signs the current user out, if one is signed in.
        Parameters:
        context - the context requesting the user be signed out
        Returns:
        A task which, upon completion, signals that the user has been signed out (Task.isSuccessful(), or that the sign-out attempt failed unexpectedly !Task.isSuccessful()).
      • delete

        @NonNull
        public com.google.android.gms.tasks.Task<Void> delete​(@NonNull
                                                              Context context)
        Delete the use from FirebaseAuth and delete any associated credentials from the Credentials API. Returns a Task that succeeds if the Firebase Auth user deletion succeeds and fails if the Firebase Auth deletion fails. Credentials deletion failures are handled silently.
        Parameters:
        context - the calling Context.
      • useEmulator

        public void useEmulator​(@NonNull
                                String host,
                                int port)
        Connect to the Firebase Authentication emulator.
        See Also:
        FirebaseAuth.useEmulator(String, int)
      • isUseEmulator

        public boolean isUseEmulator()
      • getEmulatorHost

        public String getEmulatorHost()
      • getEmulatorPort

        public int getEmulatorPort()
      • createSignInIntentBuilder

        @NonNull
        public AuthUI.SignInIntentBuilder createSignInIntentBuilder()
        Starts the process of creating a sign in intent, with the mandatory application context parameter.