FirebaseApp

public classFirebaseApp extends Object

The entry point of Firebase SDKs. It holds common configuration and state for Firebase APIs. Most applications don't need to directly interact with FirebaseApp.

Firebase APIs use the default FirebaseApp by default, unless a different one is explicitly passed to the API via FirebaseFoo.getInstance(firebaseApp).

initializeApp(FirebaseOptions) initializes the default app instance. This method should be invoked at startup.

Constant Summary

StringDEFAULT_APP_NAME

Public Method Summary

void
delete()
Deletes thisFirebaseApp object, and releases any local state and managed resources associated with it.
boolean
equals(Object o)
static List<FirebaseApp>
getApps()
Returns a list of all FirebaseApps.
staticFirebaseApp
getInstance(String name)
Returns the instance identified by the unique name, or throws if it does not exist.
staticFirebaseApp
getInstance()
Returns the default (first initialized) instance of theFirebaseApp.
String
getName()
Returns the unique name of this app.
FirebaseOptions
getOptions()
Returns the specifiedFirebaseOptions.
int
staticFirebaseApp
initializeApp(String name)
Initializes a namedFirebaseApp instance using Google Application Default Credentials.
staticFirebaseApp
initializeApp(FirebaseOptions options, String name)
Initializes a namedFirebaseApp instance using the given options.
staticFirebaseApp
initializeApp()
Initializes the defaultFirebaseApp instance using Google Application Default Credentials.
staticFirebaseApp
initializeApp(FirebaseOptions options)
Initializes the defaultFirebaseApp instance using the given options.
String

Inherited Method Summary

From class java.lang.Object
Object
clone()
boolean
equals(Object arg0)
void
finalize()
final Class<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()

Constants

public static final StringDEFAULT_APP_NAME

Constant Value: "[DEFAULT]"

Public Methods

public voiddelete()

Deletes thisFirebaseApp object, and releases any local state and managed resources associated with it. All calls to thisFirebaseApp instance will throw once this method has been called. This also releases any managed resources allocated by other services attached to this object instance (e.g.FirebaseAuth).

A no-op if delete was called before.

public booleanequals(Object o)

public static List<FirebaseApp>getApps()

Returns a list of all FirebaseApps.

public staticFirebaseAppgetInstance(String name)

Returns the instance identified by the unique name, or throws if it does not exist.

Parameters
namerepresents the name of theFirebaseApp instance.
Returns
Throws
IllegalStateExceptionif theFirebaseApp was not initialized, either viainitializeApp(FirebaseOptions, String) orgetApps().

public staticFirebaseAppgetInstance()

Returns the default (first initialized) instance of theFirebaseApp.

Throws
IllegalStateExceptionif the default app was not initialized.

public StringgetName()

Returns the unique name of this app.

publicFirebaseOptionsgetOptions()

Returns the specifiedFirebaseOptions.

public inthashCode()

public staticFirebaseAppinitializeApp(String name)

Initializes a namedFirebaseApp instance using Google Application Default Credentials. Loads additionalFirebaseOptions from the environment in the same way as theinitializeApp() method.

Throws
IllegalStateExceptionif an app with the same name has already been initialized.
IllegalArgumentExceptionif an error occurs while loading options from the environment.

public staticFirebaseAppinitializeApp(FirebaseOptions options, String name)

Initializes a namedFirebaseApp instance using the given options.

Parameters
optionsrepresents the globalFirebaseOptions
nameunique name for the app. It is an error to initialize an app with an already existing name. Starting and ending whitespace characters in the name are ignored (trimmed).
Returns
Throws
IllegalStateExceptionif an app with the same name has already been initialized.

public staticFirebaseAppinitializeApp()

Initializes the defaultFirebaseApp instance using Google Application Default Credentials. Also attempts to load additionalFirebaseOptions from the environment by looking up theFIREBASE_CONFIG environment variable. If the value of the variable starts with'{', it is parsed as a JSON object. Otherwise it is treated as a file name and the JSON content is read from the corresponding file.

Throws
IllegalStateExceptionif the default app has already been initialized.
IllegalArgumentExceptionif an error occurs while loading options from the environment.

public staticFirebaseAppinitializeApp(FirebaseOptions options)

Initializes the defaultFirebaseApp instance using the given options.

Throws
IllegalStateExceptionif the default app has already been initialized.

public StringtoString()

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2021-04-28 UTC.