FirebaseOptions.Builder

public static final class FirebaseOptions.Builder extends Object

Builder for constructing FirebaseOptions.

Public Constructor Summary

Builder()
This constructor is deprecated. Use builder() instead.
Builder(FirebaseOptions options)
This constructor is deprecated. Use toBuilder() instead.

Public Method Summary

FirebaseOptions
build()
Builds the FirebaseOptions instance from the previously set options.
FirebaseOptions.Builder
setConnectTimeout(int connectTimeout)
Sets the connect timeout for outgoing HTTP (REST) connections made by the SDK.
FirebaseOptions.Builder
setCredentials(GoogleCredentials credentials)
Sets the GoogleCredentials to use to authenticate the SDK.
FirebaseOptions.Builder
setDatabaseAuthVariableOverride(Map<String, Object> databaseAuthVariableOverride)
Sets the auth variable to be used by the Realtime Database rules.
FirebaseOptions.Builder
setDatabaseUrl(String databaseUrl)
Sets the Realtime Database URL to use for data storage.
FirebaseOptions.Builder
setFirestoreOptions(FirestoreOptions firestoreOptions)
Sets the FirestoreOptions used to initialize Firestore in the FirestoreClient API.
FirebaseOptions.Builder
setHttpTransport(HttpTransport httpTransport)
Sets the HttpTransport used to make remote HTTP calls.
FirebaseOptions.Builder
setJsonFactory(JsonFactory jsonFactory)
Sets the JsonFactory used to parse JSON when making remote HTTP calls.
FirebaseOptions.Builder
setProjectId(String projectId)
Sets the Google Cloud project ID that should be associated with an app.
FirebaseOptions.Builder
setReadTimeout(int readTimeout)
Sets the read timeout for outgoing HTTP (REST) calls made by the SDK.
FirebaseOptions.Builder
setServiceAccountId(String serviceAccountId)
Sets the client email address of the service account that should be associated with an app.
FirebaseOptions.Builder
setStorageBucket(String storageBucket)
Sets the name of the Google Cloud Storage bucket for reading and writing application data.
FirebaseOptions.Builder
setThreadManager(ThreadManager threadManager)
Sets the ThreadManager used to initialize thread pools and thread factories for Firebase apps.
FirebaseOptions.Builder
setWriteTimeout(int writeTimeout)
Sets the write timeout for outgoing HTTP (REST) calls made by the SDK.

Inherited Method Summary

Public Constructors

public Builder ()

This constructor is deprecated.
Use builder() instead.

Constructs an empty builder.

public Builder (FirebaseOptions options)

This constructor is deprecated.
Use toBuilder() instead.

Initializes the builder's values from the options object.

The new builder is not backed by this object's values, that is changes made to the new builder don't change the values of the origin object.

Public Methods

public FirebaseOptions build ()

Builds the FirebaseOptions instance from the previously set options.

Returns

public FirebaseOptions.Builder setConnectTimeout (int connectTimeout)

Sets the connect timeout for outgoing HTTP (REST) connections made by the SDK. This is used when opening a communication link to a remote HTTP endpoint. This setting does not affect the FirebaseDatabase and FirestoreClient APIs.

Parameters
connectTimeout Connect timeout in milliseconds. Must not be negative.
Returns
  • This Builder instance is returned so subsequent calls can be chained.

public FirebaseOptions.Builder setCredentials (GoogleCredentials credentials)

Sets the GoogleCredentials to use to authenticate the SDK. This parameter must be specified when creating a new instance of FirebaseOptions.

See Initialize the SDK for code samples and detailed documentation.

Parameters
credentials A GoogleCredentials instance used to authenticate the SDK.
Returns
  • This Builder instance is returned so subsequent calls can be chained.

public FirebaseOptions.Builder setDatabaseAuthVariableOverride (Map<String, Object> databaseAuthVariableOverride)

Sets the auth variable to be used by the Realtime Database rules.

When set, security rules for Realtime Database actions are evaluated using the provided auth object. During evaluation the object is available on the auth variable. Use this option to enforce schema validation and additional security for this app instance.

If this option is not provided, security rules are bypassed entirely for this app instance. If this option is set to null, security rules are evaluated against an unauthenticated user. That is, the auth variable is null.

See Authenticate with limited privileges for code samples and detailed documentation.

Parameters
databaseAuthVariableOverride The value to use for the auth variable in the security rules for Realtime Database actions.
Returns
  • This Builder instance is returned so subsequent calls can be chained.

public FirebaseOptions.Builder setDatabaseUrl (String databaseUrl)

Sets the Realtime Database URL to use for data storage.

See Initialize the SDK for code samples and detailed documentation.

Parameters
databaseUrl The Realtime Database URL to use for data storage.
Returns
  • This Builder instance is returned so subsequent calls can be chained.

public FirebaseOptions.Builder setFirestoreOptions (FirestoreOptions firestoreOptions)

Sets the FirestoreOptions used to initialize Firestore in the FirestoreClient API. This can be used to customize low-level transport (GRPC) parameters, and timestamp handling behavior.

If credentials or a project ID is set in FirestoreOptions, they will get overwritten by the corresponding parameters in FirebaseOptions.

Parameters
firestoreOptions A FirestoreOptions instance.
Returns
  • This Builder instance is returned so subsequent calls can be chained.

public FirebaseOptions.Builder setHttpTransport (HttpTransport httpTransport)

Sets the HttpTransport used to make remote HTTP calls. A reasonable default is used if not explicitly set. The transport specified by calling this method is used by all services of the SDK, except for FirebaseDatabase.

Parameters
httpTransport An HttpTransport instance
Returns
  • This Builder instance is returned so subsequent calls can be chained.

public FirebaseOptions.Builder setJsonFactory (JsonFactory jsonFactory)

Sets the JsonFactory used to parse JSON when making remote HTTP calls. A reasonable default is used if not explicitly set.

Parameters
jsonFactory A JsonFactory instance.
Returns
  • This Builder instance is returned so subsequent calls can be chained.

public FirebaseOptions.Builder setProjectId (String projectId)

Sets the Google Cloud project ID that should be associated with an app.

Parameters
projectId A non-null, non-empty project ID string.
Returns
  • This Builder instance is returned so subsequent calls can be chained.

public FirebaseOptions.Builder setReadTimeout (int readTimeout)

Sets the read timeout for outgoing HTTP (REST) calls made by the SDK. This does not affect the FirebaseDatabase and FirestoreClient APIs.

Parameters
readTimeout Read timeout in milliseconds. Must not be negative.
Returns
  • This Builder instance is returned so subsequent calls can be chained.

public FirebaseOptions.Builder setServiceAccountId (String serviceAccountId)

Sets the client email address of the service account that should be associated with an app.

This is used to create custom auth tokens when service account credentials are not available. The client email address of a service account can be found in the client_email field of the service account JSON.

Parameters
serviceAccountId A service account email address string.
Returns
  • This Builder instance is returned so subsequent calls can be chained.

public FirebaseOptions.Builder setStorageBucket (String storageBucket)

Sets the name of the Google Cloud Storage bucket for reading and writing application data. This should be the full name of the bucket as listed in the Google Cloud Platform Console, and must not include gs:// or any other protocol prefixes. The same credential used to initialize the SDK (see setCredentials(GoogleCredentials)) is used to access the bucket.

See Introduction to the Admin Cloud Storage API for code samples and detailed documentation.

Parameters
storageBucket The full name of an existing Google Cloud Storage bucket, excluding any protocol prefixes.
Returns
  • This Builder instance is returned so subsequent calls can be chained.

public FirebaseOptions.Builder setThreadManager (ThreadManager threadManager)

Sets the ThreadManager used to initialize thread pools and thread factories for Firebase apps.

Parameters
threadManager A ThreadManager instance.
Returns
  • This Builder instance is returned so subsequent calls can be chained.

public FirebaseOptions.Builder setWriteTimeout (int writeTimeout)

Sets the write timeout for outgoing HTTP (REST) calls made by the SDK. This does not affect the FirebaseDatabase and FirestoreClient APIs.

Parameters
writeTimeout Write timeout in milliseconds. Must not be negative.
Returns
  • This Builder instance is returned so subsequent calls can be chained.