clearStorage
Clears all locally stored SDK data including conversations, messages, and optionally the authorization token.
Use this when a user logs out or when you need to reset the SDK to a clean state. This operation also destroys the current CoreClient instance to clear any in-memory caches, so you must create a new instance via CoreClient.Factory after calling this.
Important: The clearAuthorization parameter has different consequences depending on whether user verification is enabled:
Verified users (
isUserVerificationRequired = true): SettingclearAuthorization = trueis safe. The user can re-verify on their next session and regain access to their existing conversations.Unverified users (
isUserVerificationRequired = false): SettingclearAuthorization = trueis destructive. The user will permanently lose access to all their conversations and a new user identity will be created on the next session. This also occurs on app reinstall or database clear, which causes previously used conversation IDs to return HTTP 403 errors.
To preserve conversation history across sessions, set clearAuthorization to false.
Return
Result.Success on successful clearing, or Result.Error if the operation fails.
Parameters
The application Context.
When true (default), removes the locally stored authorization token. Set to false to retain conversation access across sessions.
Samples
// WARNING: For unverified users, clearAuthorization = true is destructive.
// The user will permanently lose access to their conversations and a new
// user identity will be created on the next session.
//
// For verified users (isUserVerificationRequired = true), clearAuthorization = true
// is safe — the user can re-verify and regain access to their conversations.
val clearAuth = if (configuration.isUserVerificationRequired) {
true
} else {
// For unverified users, preserve the authorization token so the user
// retains access to their existing conversations
false
}
val result = CoreClient.clearStorage(context, clearAuthorization = clearAuth)