coreClient
Returns the CoreClient instance associated with this UI client.
Use the returned client to register providers (hidden pre-chat values, user verification, templated URLs), manage the real-time event stream, or perform operations that do not require the UI. When using the same com.salesforce.android.smi.core.CoreConfiguration in both UIClientFactory and com.salesforce.android.smi.core.CoreClientFactory, this returns the shared instance, allowing operations on the active client even when the UI is not displayed.
When MessagingInAppUI is not active (e.g., bottom sheet closed), the host app must call CoreClient.start and CoreClient.stop manually to maintain the real-time event stream. Do not call CoreClient.start while MessagingInAppUI is active — the composable manages the lifecycle automatically.
Return
The CoreClient singleton for the current configuration.
Parameters
The application Context. Used on first access to initialize the client.
See also
Samples
val coreClient = uiClient.coreClient(context)
// Hidden pre-chat values are used for routing decisions in Salesforce Flows
coreClient.registerHiddenPreChatValuesProvider { fields ->
fields.onEach { field ->
when (field.name) {
"Department" -> field.userInput = "Sales"
"Priority" -> field.userInput = "High"
}
}
}val coreClient = uiClient.coreClient(context)
// When MessagingInAppUI is NOT active, maintain the event stream manually.
// Do NOT call start() while MessagingInAppUI is active — it manages its own lifecycle.
LifecycleResumeEffect(Unit) {
coreClient.start(lifecycleScope)
onPauseOrDispose { coreClient.stop() }
}