Skip to main content

Profanity filter callback

By default, the message sender cannot tell whether their message has been intercepted by the Nexconn moderation service. If the app wants to notify the sender when a message is blocked due to a moderation rule, enable the sensitive content interception callback service.

Messages may be intercepted in the following situations:

  • A text message matches a Nexconn built-in global sensitive word and is not delivered to the recipient.
  • A text message matches a custom sensitive word (blocked sensitive word) you defined and is not delivered to the recipient.
  • A message is blocked by a pre-messaging webhook rule and is not delivered to the recipient.

Listen for blocked messages

Register a MessageHandler and implement onMessageBlocked. The Swift-first example below matches the current iOS SDK event signature (MessageBlockedEvent).

swift
import NexconnChatSDK

final class BlockedMessageHandler: NSObject, MessageHandler {
func onMessageBlocked(_ event: MessageBlockedEvent) {
guard let info = event.info else { return }
print("Message blocked in channel: \(info.channelIdentifier.channelId)")
print("Block type: \(info.blockType.rawValue)")
print("Message ID: \(info.messageId)")
}
}

let blockedMessageHandler = BlockedMessageHandler()
NCEngine.addMessageHandler(identifier: "BLOCKED_MESSAGE_HANDLER", handler: blockedMessageHandler)

NCBlockedMessageInfo

PropertyTypeDescription
channelIdentifierNCChannelIdentifierChannel identifier of the intercepted message
messageIdNSStringUnique ID of the intercepted message
blockTypeNCMessageBlockTypeReason the message was intercepted
extraNSStringAdditional information
sentTimeint64Send time (Unix timestamp, milliseconds)
sourceTypeNSIntegerSource type: 0 original message, 1 metadata update, 2 edited content
sourceContentNSStringContent JSON of the intercepted message or extension

NCMessageBlockType

Enum valueNumeric valueDescription
NCMessageBlockTypeGlobal1Matched a Nexconn built-in global sensitive word
NCMessageBlockTypeCustom2Matched a custom sensitive word defined in Nexconn
NCMessageBlockTypeThirdParty3Blocked by a pre-messaging webhook rule