Set a conversation extension
Set a custom business extension string on a conversation for the authenticated user.
The ex field stores custom application-defined metadata attached to a conversation. Because ex is persisted as an opaque string, the SDK does not automatically merge JSON properties; when multiple application modules share this field, define stable namespaces and preserve existing values prior to serializing the updated payload.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Identifier of the target conversation. |
ex | string | Yes | Custom extension string to persist. |
Code example
import { setConversation } from '@/uni_modules/unix-openim-sdk'
await setConversation({
conversationID,
ex: JSON.stringify({ category: 'work' }),
})If existing extension data is already stored on the conversation, parse the current value, merge your new fields, and serialize the complete object before calling setConversation().
Return value
The Promise resolves with void upon successful completion.
State changes after the call
Promise resolution indicates that the SDK persisted the extension locally and dispatched the update to the server. You can immediately update the local conversation object's ex field. The SDK then emits onConversationChanged, where you can verify the persisted state using conversationID as the primary key. If state verification is required, re-query the conversation record as described in Retrieve conversation list.
Was this page helpful?