firebase::App

#include <app.h>

Firebase application object.

Summary

firebase::App acts as a conduit for communication between all Firebase services used by an application.

For example:

#if defined(__ANDROID__)
firebase::App::Create(firebase::AppOptions(), jni_env, activity);
#else
firebase::App::Create(firebase::AppOptions());
#endif  // defined(__ANDROID__)

Constructors and Destructors

~App()

Public functions

GetJNIEnv() const
JNIEnv *
Get JNI environment, needed for performing JNI calls, set on creation.
activity() const
jobject
Get a global reference to the Android activity provided to the App on creation.
java_vm() const
JavaVM *
Get Java virtual machine, retrieved from the initial JNI environment.
name() const
const char *
Get the name of this App instance.
options() const
const AppOptions &
Get options the App was created with.

Public static functions

Create()
App *
Initializes the default firebase::App with default options.
Create(JNIEnv *jni_env, jobject activity)
App *
Initializes the default firebase::App with default options.
Create(const AppOptions & options)
App *
Initializes the default firebase::App with the given options.
Create(const AppOptions & options, JNIEnv *jni_env, jobject activity)
App *
Initializes the default firebase::App with the given options.
Create(const AppOptions & options, const char *name)
App *
Initializes a firebase::App with the given options that operates on the named app.
Create(const AppOptions & options, const char *name, JNIEnv *jni_env, jobject activity)
App *
Initializes a firebase::App with the given options that operates on the named app.
GetApps()
std::vector< App * >
Get all the apps, including the default one.
GetInstance()
App *
Get the default App, or nullptr if none has been created.
GetInstance(const char *name)
App *
Get the App with the given name, or nullptr if none have been created.

Public functions

GetJNIEnv

JNIEnv * GetJNIEnv() const 

Get JNI environment, needed for performing JNI calls, set on creation.

This is not trivial as the correct environment needs to retrieved per thread.

Details
Returns
JNI environment object.

activity

jobject activity() const 

Get a global reference to the Android activity provided to the App on creation.

Also serves as the Context needed for Firebase calls.

Details
Returns
Global JNI reference to the Android activity used to create the App. The reference count of the returned object is not increased.

java_vm

JavaVM * java_vm() const 

Get Java virtual machine, retrieved from the initial JNI environment.

Details
Returns
JNI Java virtual machine object.

name

const char * name() const 

Get the name of this App instance.

Details
Returns
The name of this App instance. If a name wasn't provided via Create(), this returns kDefaultAppName.

options

const AppOptions & options() const 

Get options the App was created with.

Details
Returns
Options used to create the App.

~App

 ~App()

Public static functions

Create

App * Create()

Initializes the default firebase::App with default options.

Details
Returns
New App instance, the App should not be destroyed for the lifetime of the application. If default options can't be loaded this will return null.

Create

App * Create(
  JNIEnv *jni_env,
  jobject activity
)

Initializes the default firebase::App with default options.

Details
Parameters
jni_env
JNI environment required to allow Firebase services to interact with the Android framework.
activity
JNI reference to the Android activity, required to allow Firebase services to interact with the Android application.
Returns
New App instance. The App should not be destroyed for the lifetime of the application. If default options can't be loaded this will return null.

Create

App * Create(
  const AppOptions & options
)

Initializes the default firebase::App with the given options.

Options are copied at initialization time, so changes to the object are ignored.

Details
Parameters
options
Options that control the creation of the App.
Returns
New App instance, the App should not be destroyed for the lifetime of the application.

Create

App * Create(
  const AppOptions & options,
  JNIEnv *jni_env,
  jobject activity
)

Initializes the default firebase::App with the given options.

Options are copied at initialization time, so changes to the object are ignored.

Details
Parameters
options
Options that control the creation of the App.
jni_env
JNI environment required to allow Firebase services to interact with the Android framework.
activity
JNI reference to the Android activity, required to allow Firebase services to interact with the Android application.
Returns
New App instance. The App should not be destroyed for the lifetime of the application.

Create

App * Create(
  const AppOptions & options,
  const char *name
)

Initializes a firebase::App with the given options that operates on the named app.

Options are copied at initialization time, so changes to the object are ignored.

Details
Parameters
options
Options that control the creation of the App.
name
Name of this App instance. This is only required when one application uses multiple App instances.
Returns
New App instance, the App should not be destroyed for the lifetime of the application.

Create

App * Create(
  const AppOptions & options,
  const char *name,
  JNIEnv *jni_env,
  jobject activity
)

Initializes a firebase::App with the given options that operates on the named app.

Options are copied at initialization time, so changes to the object are ignored.

Details
Parameters
options
Options that control the creation of the App.
name
Name of this App instance. This is only required when one application uses multiple App instances.
jni_env
JNI environment required to allow Firebase services to interact with the Android framework.
activity
JNI reference to the Android activity, required to allow Firebase services to interact with the Android application.
Returns
New App instance. The App should not be destroyed for the lifetime of the application.

GetApps

std::vector< App * > GetApps()

Get all the apps, including the default one.

GetInstance

App * GetInstance()

Get the default App, or nullptr if none has been created.

GetInstance

App * GetInstance(
  const char *name
)

Get the App with the given name, or nullptr if none have been created.