Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Update typing status

Report the current account’s active typing status within a conversation.

Copy

Report conversation typing status

Pass focus: true when the user begins typing, and pass focus: false when sending a message, blurring the input field, switching conversations, or stopping input. Typing state is transient and is never saved as a draft or message.

import sdk, { ChangeInputStatesReq } from '@openimsdk/imsdk';

const startRequest: ChangeInputStatesReq = {
  conversationID: conversationID,
  focus: true,
};
await sdk.changeInputStates(startRequest);

const stopRequest: ChangeInputStatesReq = {
  conversationID: conversationID,
  focus: false,
};
await sdk.changeInputStates(stopRequest);

Parameters

ParameterTypeRequiredDescription
conversationIDstringYesTarget conversation identifier.
focusbooleanYestrue when input starts; false when input stops.

Throttle and deduplicate typing start calls rather than sending an update on every keystroke. Promise resolution confirms that the reporting request completed, without guaranteeing immediate UI updates across remote clients.

Send direct chat typing prompt

The HarmonyOS SDK also provides typingStatusUpdate, a legacy single-chat typing prompt method that sends an ephemeral indicator string to a recipient user. It does not use conversationID and accommodates custom protocols relying on msgTip.

import sdk, { TypingStatusUpdateReq } from '@openimsdk/imsdk';

const request: TypingStatusUpdateReq = {
  recvID: receiverUserID,
  msgTip: 'typing',
};
await sdk.typingStatusUpdate(request);

Parameters

ParameterTypeRequiredDescription
recvIDstringYesRecipient user ID in a single chat.
msgTipstringYesEphemeral typing prompt string.

Return value

Both methods return Promises that resolve to void upon server acceptance.

State changes after the call

Prefer changeInputStates for modern multi-platform synchronized typing states; see Receive and query typing status for receiver handling. Avoid calling both APIs simultaneously to prevent duplicated typing indicators on receiving devices.