Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
// Send message - check moderation statusCometChat.sendTextMessage(message: textMessage) { sentMessage in if let msg = sentMessage as? TextMessage { let status = msg.getModerationStatus() // "pending" | "approved" | "disapproved" }}// Listen for moderation resultsfunc onMessageModerated(moderatedMessage: BaseMessage) { if let msg = moderatedMessage as? TextMessage { let status = msg.getModerationStatus() // Handle "approved" or "disapproved" }}
Supported types: Text, Image, Video messages only
Statuses:"pending" -> "approved" or "disapproved"
AI Moderation automatically reviews messages for inappropriate content in real-time. When a user sends a text, image, or video message, it’s held in a pending state while the moderation service analyzes it, then marked as approved or disapproved via the onMessageModerated event.getModerationStatus() is available on TextMessage and MediaMessage objects. Custom messages are not subject to moderation.
For configuring moderation rules and managing flagged messages from the dashboard, see the Moderation Overview.
When you send a text, image, or video message, check the initial moderation status:
Swift
Objective-C
let textMessage = TextMessage(receiverUid: receiverUID, text: "Hello, how are you?", receiverType: .user)CometChat.sendTextMessage(message: textMessage) { sentMessage in if let message = sentMessage as? TextMessage { if message.getModerationStatus() == "pending" { print("Message is under moderation review") } }} onError: { error in print("Message sending failed: \(error?.errorDescription ?? "")")}
TextMessage *textMessage = [[TextMessage alloc] initWithReceiverUid:receiverUID text:@"Hello, how are you?" receiverType:ReceiverTypeUser];[CometChat sendTextMessageWithMessage:textMessage onSuccess:^(TextMessage *sentMessage) { if ([[sentMessage getModerationStatus] isEqualToString:@"pending"]) { NSLog(@"Message is under moderation review"); }} onError:^(CometChatException *error) { NSLog(@"Message sending failed: %@", error.errorDescription);}];
When a message is disapproved, handle it appropriately in your UI:
Swift
Objective-C
func handleDisapprovedMessage(_ message: BaseMessage) { let messageId = message.id // Option 1: Hide the message completely hideMessageFromUI(messageId) // Option 2: Show a placeholder message showBlockedPlaceholder(messageId, text: "This message was blocked by moderation") // Option 3: Notify the sender (if it's their message) if message.sender?.uid == currentUserUID { showNotification("Your message was blocked due to policy violation") }}
- (void)handleDisapprovedMessage:(BaseMessage *)message { int messageId = message.id; [self hideMessageFromUI:messageId]; [self showBlockedPlaceholder:messageId text:@"This message was blocked by moderation"]; if ([message.sender.uid isEqualToString:currentUserUID]) { [self showNotification:@"Your message was blocked due to policy violation"]; }}
Always remove listeners when they’re no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.