Typing Status
Applications can send the current user's typing status in one-to-one chat sessions. Upon receiving the notification, the recipient can display "xxx is typing" in the UI.
Sending Typing Status Messages
Call sendTypingStatus when the current user is entering text to send the typing status.
The IMLib SDK internally enforces that the same user can only send one typing status message to the same conversation within a 6-second interval. The processing interval for receiving typing status messages from the same conversation is also 6 seconds by default. This configuration cannot currently be modified.
Interface Prototype
- (void)sendTypingStatus:(RCConversationType)conversationType
targetId:(NSString *)targetId
contentType:(NSString *)objectName;
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| conversationType | RCConversationType | Conversation type. This interface only supports one-to-one chat. |
| targetId | NSString | Conversation ID |
| objectName | NSString | The type name of the message being entered. For text messages, use [RCTextMessage getObjectName] to get the type name. |
Example Code
[[RCCoreClient sharedCoreClient] sendTypingStatus:self.conversationType
targetId:self.targetId
contentType:[RCTextMessage getObjectName]];
Monitoring Typing Status
Applications can use setRCTypingStatusDelegate to set the RCTypingStatusDelegate delegate and monitor typing status notifications received in one-to-one chat sessions. When a typing status notification is received from the other party, the SDK will return the current list of users who are typing and the message type through the onTypingStatusChanged callback method.
Setting the Delegate
[[RCCoreClient sharedCoreClient] setRCTypingStatusDelegate:self];
Delegate Method
@protocol RCTypingStatusDelegate <NSObject>
/*!
Callback for changes in user typing status
@param conversationType Conversation type
@param targetId Target conversation ID
@param userTypingStatusList List of RCUserTypingStatus objects indicating who is currently typing (nil means no users are currently typing)
@discussion
This callback is triggered when the client detects a change in user typing status, notifying the affected conversation and the current list of RCUserTypingStatus objects.
@warning Currently only supports one-to-one chats.
*/
- (void)onTypingStatusChanged:(RCConversationType)conversationType
targetId:(NSString *)targetId
status:(NSArray *)userTypingStatusList;
@end