create

abstract fun create(context: Context, configuration: Configuration): CoreClient

Creates or retrieves the CoreClient singleton instance for the given configuration.

This method is safe to call multiple times. If a CoreClient already exists for the provided configuration, the existing instance is returned. When using the same CoreConfiguration in both this factory and the UIClient factory, the UI client will share the same CoreClient instance. This allows the host app to perform operations on the active client (e.g., sending messages, registering providers) even when the UI is not active.

After obtaining the client, register any providers (e.g., CoreClient.registerUserVerificationProvider, CoreClient.registerHiddenPreChatValuesProvider) before calling CoreClient.start.

Return

The CoreClient instance for this configuration.

Parameters

context

An Android Context. The application context is used internally.

configuration

The Configuration defining the deployment to connect to. Use CoreConfiguration.fromFile or construct a CoreConfiguration directly.

Samples

val configuration = CoreConfiguration(
    serviceAPI = URL("https://myorg.my.salesforce-scrt.com"),
    organizationId = "00D000000000001",
    developerName = "My_Messaging_Deployment"
)
val coreClient = CoreClient.Factory.create(context, configuration)