-
- All Implemented Interfaces:
public final class ChatClient.Builder extends ChatClient.ChatClientBuilder
Builder to initialize the singleton ChatClient instance and configure its parameters.
-
-
Constructor Summary
Constructors Constructor Description ChatClient.Builder(String apiKey, Context appContext)
-
Method Summary
Modifier and Type Method Description final ChatClient.BuilderlogLevel(ChatLogLevel level)Sets the log level to be used by the client. final ChatClient.BuilderloggerHandler(ChatLoggerHandler loggerHandler)Sets a ChatLoggerHandler instance that will receive log events from the SDK. final ChatClient.BuilderclientDebugger(ChatClientDebugger clientDebugger)Sets a ChatClientDebugger instance that will be invoked accordingly through various flows within SDK. final ChatClient.Buildernotifications(NotificationConfig notificationConfig, NotificationHandler notificationsHandler)Sets a custom NotificationHandler that the SDK will use to handle everything around push notifications. final ChatClient.Buildernotifications(NotificationConfig notificationConfig)Sets a custom NotificationHandler that the SDK will use to handle everything around push notifications. final ChatClient.BuilderfileUploader(FileUploader fileUploader)Sets a custom file uploader implementation that will be used by the client to upload files and images. final ChatClient.BuilderdisableWarmUp()By default, ChatClient performs a dummy HTTP call to the Stream API when a user is set to initialize the HTTP connection and make subsequent requests reusing this connection execute faster. final ChatClient.BuilderokHttpClient(OkHttpClient okHttpClient)Sets a custom OkHttpClient that will be used by the client to perform API calls to Stream. final ChatClient.BuilderbaseUrl(String value)Sets the base URL to be used by the client. final ChatClient.BuilderwithRepositoryFactoryProvider(RepositoryFactory.Provider provider)Inject a RepositoryFactory.Provider to use your own DB Persistence mechanism. final ChatClient.BuilderwithPlugin(PluginFactory pluginFactory)Adds a plugin factory to be used by the client. final ChatClient.BuildercredentialStorage(UserCredentialStorage credentialStorage)Overrides a default, based on shared preferences implementation for UserCredentialStorage. final ChatClient.BuilderdebugRequests(Boolean shouldDebug)Debug requests using ApiRequestsAnalyser. final ChatClient.BuilderretryPolicy(RetryPolicy retryPolicy)Sets a custom RetryPolicy used to determine whether a particular call should be retried. final ChatClient.BuilderdisableDistinctApiCalls()Allows simultaneous network calls of the same request, avoiding combining them into one. ChatClientbuild()Create a ChatClient instance based on the current configuration of the Builder. ChatClientinternalBuild()-
-
Constructor Detail
-
ChatClient.Builder
ChatClient.Builder(String apiKey, Context appContext)
- Parameters:
apiKey- The API key of your Stream Chat app obtained from the Stream Dashboard.appContext- The application Context.
-
-
Method Detail
-
logLevel
final ChatClient.Builder logLevel(ChatLogLevel level)
Sets the log level to be used by the client.
See ChatLogLevel for details about the available options.
We strongly recommend using ChatLogLevel.NOTHING in production builds, which produces no logs.
- Parameters:
level- The log level to use.
-
loggerHandler
final ChatClient.Builder loggerHandler(ChatLoggerHandler loggerHandler)
Sets a ChatLoggerHandler instance that will receive log events from the SDK.
Use this to forward SDK events to your own logging solutions.
See the FirebaseLogger class in the UI Components sample app for an example implementation.
- Parameters:
loggerHandler- Your custom ChatLoggerHandler implementation.
-
clientDebugger
final ChatClient.Builder clientDebugger(ChatClientDebugger clientDebugger)
Sets a ChatClientDebugger instance that will be invoked accordingly through various flows within SDK.
Use this to debug SDK inner processes like Message sending.
- Parameters:
clientDebugger- Your custom ChatClientDebugger implementation.
-
notifications
@JvmOverloads() final ChatClient.Builder notifications(NotificationConfig notificationConfig, NotificationHandler notificationsHandler)
Sets a custom NotificationHandler that the SDK will use to handle everything around push notifications. Create your own subclass and override methods to customize notification appearance and behavior.
See the Push Notifications documentation for more information.
- Parameters:
notificationConfig- Config push notification.notificationsHandler- Your custom class implementation of NotificationHandler.
-
notifications
@JvmOverloads() final ChatClient.Builder notifications(NotificationConfig notificationConfig)
Sets a custom NotificationHandler that the SDK will use to handle everything around push notifications. Create your own subclass and override methods to customize notification appearance and behavior.
See the Push Notifications documentation for more information.
- Parameters:
notificationConfig- Config push notification.
-
fileUploader
final ChatClient.Builder fileUploader(FileUploader fileUploader)
Sets a custom file uploader implementation that will be used by the client to upload files and images.
The default implementation uses Stream's own CDN to store these files, which has a 100 MB upload size limit.
For more info, see the File Uploads documentation.
- Parameters:
fileUploader- Your custom implementation of FileUploader.
-
disableWarmUp
final ChatClient.Builder disableWarmUp()
By default, ChatClient performs a dummy HTTP call to the Stream API when a user is set to initialize the HTTP connection and make subsequent requests reusing this connection execute faster.
Calling this method disables this connection warm-up behavior.
-
okHttpClient
final ChatClient.Builder okHttpClient(OkHttpClient okHttpClient)
Sets a custom OkHttpClient that will be used by the client to perform API calls to Stream.
Use this to configure parameters like timeout values, or to add interceptors to process all network requests.
- Parameters:
okHttpClient- The client to use for API calls.
-
baseUrl
final ChatClient.Builder baseUrl(String value)
Sets the base URL to be used by the client.
By default, this is the URL of Stream's Edge API Infrastructure, which provides low latency regardless of which region your Stream app is hosted in.
You should only change this URL if you're on dedicated Stream Chat infrastructure.
- Parameters:
value- The base URL to use.
-
withRepositoryFactoryProvider
final ChatClient.Builder withRepositoryFactoryProvider(RepositoryFactory.Provider provider)
Inject a RepositoryFactory.Provider to use your own DB Persistence mechanism.
-
withPlugin
final ChatClient.Builder withPlugin(PluginFactory pluginFactory)
Adds a plugin factory to be used by the client.
- Parameters:
pluginFactory- The factory to be added.
-
credentialStorage
final ChatClient.Builder credentialStorage(UserCredentialStorage credentialStorage)
Overrides a default, based on shared preferences implementation for UserCredentialStorage.
-
debugRequests
final ChatClient.Builder debugRequests(Boolean shouldDebug)
Debug requests using ApiRequestsAnalyser. Use this to debug your requests. This shouldn't be enabled in release builds as it uses a memory cache.
-
retryPolicy
final ChatClient.Builder retryPolicy(RetryPolicy retryPolicy)
Sets a custom RetryPolicy used to determine whether a particular call should be retried. By default, no calls are retried.
- Parameters:
retryPolicy- Custom RetryPolicy implementation.
-
disableDistinctApiCalls
final ChatClient.Builder disableDistinctApiCalls()
Allows simultaneous network calls of the same request, avoiding combining them into one. By default distinctApiCalls is enabled.
-
build
ChatClient build()
Create a ChatClient instance based on the current configuration of the Builder.
-
internalBuild
@Deprecated(message = "It shouldn't be used outside of SDK code. Created for testing purposes", replaceWith = @ReplaceWith(imports = {}, expression = "this.build()"), level = DeprecationLevel.ERROR) ChatClient internalBuild()
-
-
-
-