CoreClient
The entry point for the Messaging for In-App SDK.
A CoreClient instance manages conversations, handles real-time messaging events, authentication, and push notification registration. Use this client to create and manage conversations, observe messaging events, and coordinate with the backend service.
Obtain an instance using CoreClientFactory:
val configuration = CoreConfiguration(
serviceAPI = URL("https://myorg.my.salesforce-scrt.com"),
organizationId = "00D000000000001",
developerName = "My_Messaging_Deployment"
)
val coreClient = CoreClient.Factory.create(context, configuration)To begin receiving real-time events, call start with a CoroutineScope. The host app is responsible for maintaining this scope — when the scope is cancelled, the connection closes. When the client is started, push notifications are suppressed in favor of real-time delivery. Call stop to resume push notification delivery.
A typical setup registers providers and manages the connection via Compose lifecycle:
val coreClient = CoreClient.Factory.create(context, configuration).apply {
registerHiddenPreChatValuesProvider { fields ->
fields.onEach { it.userInput = resolveValue(it.name) }
}
if (configuration.isUserVerificationRequired) {
registerUserVerificationProvider { reason ->
UserVerificationToken.externalToken(fetchJwt())
}
}
}
// In a Composable, tie the event stream to the lifecycle
LifecycleResumeEffect(Unit) {
coreClient.start(lifecycleScope)
onPauseOrDispose { coreClient.stop() }
}See also
Types
Properties
Gets the Configuration that this instance is configured with.
Observes the current network connectivity status.
Observes the state of the real-time connection to the messaging service.
The endpoint URL path for Salesforce authentication requests, derived from the current Configuration.
Functions
Closes a conversation, ending the messaging session permanently.
Returns a ConversationClient for interacting with a specific conversation.
Retrieves conversations from the local cache sorted by latest activity.
Retrieves conversations available to the local participant.
Retrieves conversations from the local cache sorted by latest activity as a Flow.
Retrieves conversations available to the local participant as a Flow.
Retrieves conversations available to the local participant with pagination support.
Retrieves conversations from the local cache sorted by latest activity with pagination support.
Creates a new conversation with the messaging service.
Deletes a conversation and its entries from the local database.
Deregisters this device from receiving push notifications for this deployment.
Destroys this CoreClient instance and releases all associated resources.
Sends a read acknowledgement for a ConversationEntry.
Returns a MultimediaClient for managing voice and video sessions.
Registers this device for push notifications using the provided FCM device token.
Registers a provider for supplying hidden pre-chat field values.
Registers a provider for supplying templated URL values for an auto-response messaging component.
Registers a provider for verifying an already authenticated user.
Retrieves the BusinessHoursInfo for the current deployment.
Retrieves the RemoteConfiguration from the messaging service.
Revokes the current authorization token, preventing further operations until a new token is granted.