Typing Status
The IMLib SDK can send the current user's typing status to ultra groups. Users who receive the notification in the ultra group can display "xxx is typing" in the UI.
tip
For optimal experience, it is recommended to use this feature only in ultra groups with fewer than 10,000 members.
Send Typing Status
You can call sendUltraGroupTypingStatus when the current user is entering text to send the typing status.
Interface Prototype
- (void)sendUltraGroupTypingStatus:(NSString *)targetId
channleId:(NSString *)channelId
typingStatus:(RCUltraGroupTypingStatus)status
success:(void (^)(void))successBlock
error:(void (^)(RCErrorCode status))errorBlock
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| targetId | NSString | Ultra group conversation targetId. |
| channelId | NSString | Ultra group channel channelId. |
| status | RCUltraGroupTypingStatus | Typing status type. |
| successBlock | Block | Success callback. |
| errorBlock | Block | Failure callback. status contains the error code [RCErrorCode]. |
Example Code
[[RCChannelClient sharedChannelManager] sendUltraGroupTypingStatus:@"targetId"
channelId:@"channelId"
typingStatus:RCUltraGroupTypingStatusText success:^() {
} error:^(RCErrorCode status) {
}];
Monitor Typing Status
To reduce pressure on the server and client, the server aggregates user typing events over a period (e.g., 5 seconds) and sends them in batches. Therefore, the callback is provided as an array. When the client receives the notification, it can display "xxx is typing" in the UI.
- Set the typing status delegate:
[[RCChannelClient sharedChannelManager] setRCUltraGroupTypingStatusDelegate:self];
- Implement the typing status delegate method:
/*!
Callback for changes in user typing status.
@param infoArr List of RCUltraGroupTypingStatusInfo objects indicating who is typing (nil means no users are currently typing).
@discussion
This callback is triggered when the client receives changes in user typing status, notifying the affected conversation and the current list of RCUltraGroupTypingStatusInfo objects.
*/
- (void)onUltraGroupTypingStatusChanged:(NSArray<RCUltraGroupTypingStatusInfo*>*)infoArr {
}
Description of RCUltraGroupTypingStatusInfo properties in the callback:
@interface RCUltraGroupTypingStatusInfo : NSObject
/*!
Conversation ID
*/
@property (nonatomic, copy) NSString *targetId;
/*!
Business identifier of the conversation
*/
@property (nonatomic, copy) NSString *channelId;
/*!
User ID
*/
@property (nonatomic, copy) NSString *userId;
/*!
Number of users
*/
@property (nonatomic, assign) NSInteger userNumbers;
/*!
Typing status
*/
@property (nonatomic, assign) RCUltraGroupTypingStatus status;
/*!
Timestamp when the server received the user action.
*/
@property (nonatomic, assign) long long timestamp;
@end