Message Block Notification Callback
The SDK supports the Message Block Notification Callback starting from version 5.1.4.
By default, message senders cannot detect whether their messages have been blocked by the sensitive word filtering mechanism. If your app needs to notify senders when messages are blocked due to triggering sensitive words, you can enable the Message Block Notification Callback service.
RC's content moderation services (including message sensitive words and message callback service) may block messages in the following scenarios:
- Text message content triggers RC's built-in sensitive word filters, preventing message delivery to recipients.
- Text message content triggers your custom sensitive word filters (blocked terms), preventing message delivery to recipients.
- Messages trigger moderation rules set by Message Callback Service, preventing message delivery to recipients.
Enabling the Service
You can enable this feature in the RC Console under Chat > Chat settings > Security & Moderation > Blocked Message Status Callback to Sender.
Setting Up the Message Block Delegate
Note
This interface is available in
RCCoreClient.
[RCCoreClient sharedCoreClient].messageBlockDelegate = self;
Implementing the Message Block Delegate Methods
When sent messages are blocked, the IMLib SDK triggers the following method in RCMessageBlockDelegate:
@protocol RCMessageBlockDelegate <NSObject>
/*!
Callback when a sent message is blocked
@param blockedMessageInfo Information about the blocked message
*/
- (void)messageDidBlock:(RCBlockedMessageInfo *)blockedMessageInfo;
@end
RCBlockedMessageInfo contains details about the blocked message:
| Parameter | Type | Description |
|---|---|---|
| type | RCConversationType | Conversation type of the blocked message |
| targetId | NSString | Conversation ID where the message was blocked |
| channelId | NSString | Ultra group channel ID where the message was blocked (Supported in iOS SDK v5.2.4+) |
| blockedMsgUId | NSString | Unique ID of the blocked message |
| blockType | RCMessageBlockType | Reason for blocking (see RCMessageBlockType below) |
| extra | NSString | Additional information about the blocked message |
| sentTime | long long | Timestamp when the message was sent (Unix timestamp, milliseconds). Supported in iOS SDK v5.2.4+. |
| sourceType | NSInteger | Source type of blocked ultra group messages. 0: Original message triggered blocking (default). 1: Message extension triggered blocking. 2: Modified message content triggered blocking. Supported in iOS SDK v5.2.5+ (ultra groups only). |
| sourceContent | NSString | JSON string of blocked ultra group message/extension content. When sourceType=1, shows extension content. When sourceType=2, shows modified message content. See sourceContent below. Supported in iOS SDK v5.2.5+ (ultra groups only). |
-
RCMessageBlockTypeDetailstypedef NS_ENUM(NSUInteger, RCMessageBlockType) {
/*!
Global sensitive word: Triggered RC's built-in global sensitive words
*/
RCMessageBlockTypeGlobal = 1,
/*!
Custom sensitive word: Triggered client-defined sensitive words
*/
RCMessageBlockTypeCustom = 2,
/*!
Third-party moderation: Blocked by third-party (e.g., Shumei) or Message Callback Service (original template routing service)
*/
RCMessageBlockTypeThirdParty= 3,
}; -
sourceContentDetails- When
sourceType=0, sourceContent is nil. - When
sourceType=1, sourceContent contains message extension data, e.g.,{"mid":"xxx-xxx-xxx-xxx","put":{"key":"sensitive_word"}}. "mid" is the notification message ID. - When
sourceType=2, sourceContent contains modified message content, e.g.,{"content":"text_with_sensitive_content"}. For built-in message types, refer to Message Type Overview.
- When