-
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.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.BuilderbaseTimeout(Long timeout)final ChatClient.BuildercdnTimeout(Long timeout)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.BuildercallbackExecutor(Executor callbackExecutor)final ChatClient.BuilderwithPlugin(Plugin plugin)final ChatClient.BuildercredentialStorage(UserCredentialStorage credentialStorage)Overrides a default, based on shared preferences implementation for UserCredentialStorage. 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.
-
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 20 MB upload size limit.
For more info, see the File Uploads documentation.
- Parameters:
fileUploader- Your custom implementation of FileUploader.
-
baseTimeout
@Deprecated(message = Use okHttpClient() to set the timeouts, level = DeprecationLevel.ERROR) final ChatClient.Builder baseTimeout(Long timeout)
-
cdnTimeout
@Deprecated(message = Use okHttpClient() to set the timeouts, level = DeprecationLevel.ERROR) final ChatClient.Builder cdnTimeout(Long timeout)
-
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.
-
callbackExecutor
final ChatClient.Builder callbackExecutor(Executor callbackExecutor)
-
withPlugin
final ChatClient.Builder withPlugin(Plugin plugin)
-
credentialStorage
final ChatClient.Builder credentialStorage(UserCredentialStorage credentialStorage)
Overrides a default, based on shared preferences implementation for UserCredentialStorage.
-
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()
-
-
-
-