Browse SDKs · React Native
SDKsReact Native

Update input states

OpenIM React Native SDK guide for update input states.

Copy

Use changeInputStates() to update the current account's input state in a conversation. Pass focus: true while typing, and false after sending, losing focus, or leaving the conversation.

await OpenIMSDK.changeInputStates({
  conversationID,
  focus: true,
});

Parameters

ParameterTypeRequiredDescription
conversationIDstringYesConversation whose input state is updated.
focusbooleanYestrue means the user is typing; false means typing has stopped.

Avoid reporting the same state on every keyboard event. When the state changes, OnInputStatusChanged is emitted with conversationID, userID, and platformIDs.

function handleInputStatusChanged(inputStatus) {
  // ...
}

// Set the listener
OpenIMSDK.on(OpenIMEvent.OnInputStatusChanged, handleInputStatusChanged);

// Remove the listener
OpenIMSDK.off(OpenIMEvent.OnInputStatusChanged, handleInputStatusChanged);

Remove the listener when the component is destroyed, the account signs out, or the account changes.