> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Flag Message

> The report dialog: your app's flag reasons as single-select chips, an optional remark, and Report, over a dimmed chat.

`CometChatFlagMessage` is the dialog a user reports a message with: a title with a close
button, a description, your app's flag reasons as chips, an optional remark, and **Cancel**
/ **Report**, centred over a 40 % scrim. The [message list](https://www.cometchat.com/docs/ui-kit/ios/v6/message-list.md)
opens it from the **Report** option on someone else's message. You can also present it
yourself.

![CometChatFlagMessage showing report reasons, an optional remark and the Report button](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-overview-flag-message.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=6e99db5d2b4df6aa4f524bfda9795a7a)

***

## Where It Fits

```
CometChatMessageList
        │ Report option (someone else's message)
        ▼
┌───────────────────────────────┐
│ CometChatFlagMessage  ← here  │   over a 40 % scrim, full screen
└───────────────────────────────┘
        │ onReportClick(FlagDetail)
        ▼
   the list flags the message
```

The dialog opens at once with no chips; the reasons arrive when CometChat answers. Flag
reasons are configured in your CometChat dashboard's moderation settings.

The message list presents the dialog itself, flags the message on **Report**, dismisses it
on success and shows its error line on failure. From the list you choose whether the option
and the remark field show:

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatMessageList(user: user,
>                      hideFlagOption: false,
>                      hideFlagRemarkInputField: true)
> ```
>
> The list passes nothing else to the dialog. Style it through the theme and the slot
> modifiers under Custom View Slots, which reach the list's dialog too.

> [tab] UIKit
>
> ```swift theme={null}
> let list = CometChatMessageList()
> list.hideFlagMessageOption = false
> list.hideFlagRemarkFeild = true
> ```

***

## Quick Start

> [tab] SwiftUI
>
> `CometChatFlagMessage` is a `View`. Present it full screen over a clear background. With no
> `onReportClick`, the dialog flags the message itself, closes through `onDismiss` when that
> succeeds and shows its error line when it fails:
>
> ```swift theme={null}
> struct ReportButton: View {
>     let message: BaseMessage
>     @State private var reporting = false
>
>     var body: some View {
>         Button("Report") { reporting = true }
>             .fullScreenCover(isPresented: $reporting) {
>                 CometChatFlagMessage(message: message,
>                                      onCancelClick: { reporting = false },
>                                      onError: { error in print(error.code) })
>                     .presentationBackground(.clear)
>             }
>     }
> }
> ```
>
> `onCloseClick` (the X) and `onDismiss` (a tap on the scrim, or a successful report) fall
> back to `onCancelClick`. A tap on the scrim does nothing unless `dismissOnClickOutside` is
> `true`.

> [tab] UIKit
>
> `CometChatFlagMessage` is a `UIViewController`. Present it over the current screen. With no
> handler, the dialog flags the message itself and dismisses when that succeeds:
>
> ```swift theme={null}
> final class ReportPresenter {
>     func report(_ message: BaseMessage, from controller: UIViewController) {
>         let dialog = CometChatFlagMessage()
>             .set(messageId: message.id)
>             .set(onError: { error in print(error.localizedDescription) })
>         controller.present(dialog, animated: false)
>     }
> }
> ```
>
> The dialog is created with `.overFullScreen`, so present it unanimated.

***

## What It Shows

| Region | Shows |
| - | - |
| title | "Report" and a close button |
| description | "Report this chat if it goes against our Community Standards. We won't tell the account you reported them." |
| reasons | one chip per line; the list stops growing at 210 pt and scrolls |
| remark | "Reason (Optional)" and a 90 pt field |
| buttons | **Cancel**, and **Report** — dimmed until a reason is selected; a spinner while reporting |
| error | "Failed to report message", under the buttons |

The `spam`, `sexual` and `harassment` reasons read "Spam / Unwanted Content", "Sexual
Content" and "Harassment / Bullying". Other reasons show the name your dashboard gives
them. While the reasons load, or if fetching them fails, there are no chips and **Report**
cannot be tapped.

> [tab] SwiftUI
>
> Hide the remark and its title with `showRemarkField: false`. Translate or rename any reason
> with `localizationMap`, keyed by the reason's id in lower case:
>
> ```swift theme={null}
> CometChatFlagMessage(message: reportedMessage,
>                      localizationMap: ["spam": "Junk", "impersonation": "Pretending to be someone"])
> ```
>
> The five texts can be replaced with `title`, `description`, `remarkHint`,
> `cancelButtonText` and `reportButtonText`. An empty string shows an empty line.

> [tab] UIKit
>
> Hide the remark and its title with `hideFlagRemarkFeild`. `flagReasonLocalizer` is asked
> first, with the reason's id in lower case; a non-empty answer wins:
>
> ```swift theme={null}
> let dialog = CometChatFlagMessage()
> dialog.flagReasonLocalizer = { id in id == "impersonation" ? "Pretending to be someone" : "" }
> dialog.set(title: "Report this message").set(reportButtonText: "Send")
> ```

On iOS 26 the card is Liquid Glass when the render path is `.glass` (the default) and
Reduce Transparency is off. Everywhere else, including iOS 18–25, it is an opaque card.

> [tab] SwiftUI
>
> The scrim, the 18 pt corners and everything inside the card are the same on both:
>
> ```swift theme={null}
> CometChatFlagMessage(message: reportedMessage)
>     .cometChatRenderPath(.fallback)   // the opaque card on every OS
> ```

> [tab] UIKit
>
> The render path is `CometChatUIKitTheme.shared.renderPath`.

***

## Actions and Events

### Callback Methods

> [tab] SwiftUI
>
> | Parameter | Signature | When |
> | - | - | - |
> | `onReportClick` | `(FlagDetail) -> Void` | **Report**, with a reason selected. With none, the dialog flags the message itself |
> | `onCancelClick` | `() -> Void` | **Cancel** |
> | `onCloseClick` | `() -> Void` | the X — defaults to `onCancelClick` |
> | `onDismiss` | `() -> Void` | a tap on the scrim, or a successful report — defaults to `onCancelClick` |
> | `onError` | `(CometChatError) -> Void` | the reasons could not be fetched, or the dialog's own report failed |
>
> To flag the message yourself, take the SDK's `FlagDetail` from `onReportClick` and drive
> the dialog's spinner and error line:
>
> ```swift theme={null}
> struct MyReportDialog: View {
>     let message: BaseMessage
>     let close: () -> Void
>     @State private var submitting = false
>     @State private var failed = false
>
>     var body: some View {
>         CometChatFlagMessage(message: message,
>                              showError: failed,
>                              showProgress: submitting,
>                              onReportClick: { detail in
>                                  submitting = true
>                                  Task {
>                                      if await Self.flag(messageId: detail.messageId, reasonId: detail.reasonId, remark: detail.remark) {
>                                          close()
>                                      } else {
>                                          submitting = false
>                                          failed = true
>                                      }
>                                  }
>                              },
>                              onCancelClick: close)
>     }
>
>     /// CometChat's flag call, awaited: `true` once the message is flagged.
>     /// `nonisolated` matters: the SDK calls back on a background queue, and a
>     /// continuation created on the main actor traps when it is resumed there.
>     /// It takes the detail's values, not the `FlagDetail`, which is not `Sendable`.
>     nonisolated static func flag(messageId: Int, reasonId: String, remark: String?) async -> Bool {
>         let detail = FlagDetail(messageId: messageId, reasonId: reasonId, remark: remark)
>         return await withCheckedContinuation { continuation in
>             CometChat.flagMessage(messageId: messageId, detail: detail,
>                                   onSuccess: { _ in continuation.resume(returning: true) },
>                                   onError: { _ in continuation.resume(returning: false) })
>         }
>     }
> }
> ```

> [tab] UIKit
>
> | Setter | Signature | Called | Without it |
> | - | - | - | - |
> | `set(onReport:)` | `(FlagDetail) -> Void` | **Report**, with a reason selected | the dialog flags the message itself |
> | `set(onCancel:)` | `() -> Void` | **Cancel** | the dialog dismisses |
> | `set(onClose:)` | `() -> Void` | the X | the dialog dismisses |
> | `set(onError:)` | `(NSError) -> Void` | the reasons could not be fetched, or the dialog's own report failed | — |
>
> The delegate, `CometChatFlagMessageDelegate`, has the same four as optional methods; its
> `onReport(_:reasonId:remark:)` carries the reason's id and the remark. A closure or a
> delegate method set means you handle the action, and the dialog does nothing else.
>
> To flag the message yourself, drive the spinner and the error line:
>
> ```swift theme={null}
> @MainActor
> final class ModeratedReport {
>     func present(_ message: BaseMessage, from controller: UIViewController) {
>         let dialog = CometChatFlagMessage().set(messageId: message.id)
>         dialog.set(onReport: { [weak dialog] detail in
>             dialog?.startReporting()
>             Task { @MainActor in
>                 if await Self.flag(messageId: detail.messageId, reasonId: detail.reasonId, remark: detail.remark) {
>                     dialog?.dismiss(animated: false)
>                 } else {
>                     dialog?.stopReporting()
>                     dialog?.showError(true)
>                 }
>             }
>         })
>         controller.present(dialog, animated: false)
>     }
>
>     /// CometChat's flag call, awaited: `true` once the message is flagged.
>     /// `nonisolated` matters: the SDK calls back on a background queue, and a
>     /// continuation created on the main actor traps when it is resumed there.
>     /// It takes the detail's values, not the `FlagDetail`, which is not `Sendable`.
>     nonisolated static func flag(messageId: Int, reasonId: String, remark: String?) async -> Bool {
>         let detail = FlagDetail(messageId: messageId, reasonId: reasonId, remark: remark)
>         return await withCheckedContinuation { continuation in
>             CometChat.flagMessage(messageId: messageId, detail: detail,
>                                   onSuccess: { _ in continuation.resume(returning: true) },
>                                   onError: { _ in continuation.resume(returning: false) })
>         }
>     }
> }
> ```
>
> A tap on the scrim dismisses the dialog and tells no one. Set `dismissOnTapOutside = false`
> and the tap only ends editing.

***

## Functionality

> [tab] SwiftUI
>
> | Parameter | Type | Default |
> | - | - | - |
> | `message` | `BaseMessage` | required |
> | `store` | `CometChatFlagMessageStore?` | `nil` |
> | `flagReasons` | `[FlagReason]?` | `nil` — fetched. Pass reasons you already have and nothing is fetched |
> | `style` | `CometChatFlagMessageStyle` | |
> | `localizationMap` | `[String: String]` | `[:]` |
> | `title` | `String?` | `nil` |
> | `description` | `String?` | `nil` |
> | `remarkHint` | `String?` | `nil` |
> | `cancelButtonText` | `String?` | `nil` |
> | `reportButtonText` | `String?` | `nil` |
> | `showRemarkField` | `Bool` | `true` |
> | `showError` | `Bool` | `false` |
> | `showProgress` | `Bool` | `false` |
> | `dismissOnClickOutside` | `Bool` | `false` |
>
> Reasons are fetched every time the dialog opens.

> [tab] UIKit
>
> | Setter / property | Type | Notes |
> | - | - | - |
> | `set(messageId:)` | `Int` | |
> | `set(reasons:)` | `[FlagReason]` | preloaded; nothing is fetched |
> | `set(store:)` | `CometChatFlagMessageStore` | |
> | `set(title:)`, `set(description:)`, `set(remarkHint:)`, `set(cancelButtonText:)`, `set(reportButtonText:)` | `String?` | |
> | `hideFlagRemarkFeild` | `Bool` | |
> | `flagReasonLocalizer` | `((String) -> String)?` | |
> | `dismissOnTapOutside` | `Bool` | default `true` |
> | `style` | `FlagMessageStyle` | `CometChatFlagMessage.style` is the default every new dialog copies |
> | `delegate` | `CometChatFlagMessageDelegate` | |

***

## Custom View Slots

> [tab] SwiftUI
>
> Replace the title line, the chips, the remark or the buttons, for every flag-message dialog
> in a subtree — the list's included. Each closure gets the values the default region uses:
>
> ```swift theme={null}
> MyScreen()
>     .cometChatFlagMessageTitleView { title, onClose in
>         HStack {
>             Label(title, systemImage: "flag")
>             Spacer()
>             Button("Done", action: onClose)
>         }
>     }
>     .cometChatFlagMessageFooterView { isReportEnabled, showProgress, onCancel, onReport in
>         HStack {
>             Button("Not now", action: onCancel)
>             Button(showProgress ? "Sending…" : "Send", action: onReport)
>                 .disabled(!isReportEnabled)
>         }
>     }
> ```
>
> The reasons view gets the reasons, the selected id and `onSelect(id)`; the remark view a
> `Binding<String>`. Without `onSelect`, nothing can be selected and **Report** stays
> disabled. The modifiers are `cometChatFlagMessageTitleView`,
> `cometChatFlagMessageReasonsView`, `cometChatFlagMessageRemarkView` and
> `cometChatFlagMessageFooterView`.

> [tab] UIKit
>
> There are no slot setters. To change a region, subclass the `open` dialog — see Advanced
> Methods.

***

## Advanced Methods

### Store Access

> [tab] SwiftUI
>
> `CometChatFlagMessageStore` fetches the reasons and holds the selection and the remark.
> Pass your own to preview the dialog without a session:
>
> ```swift theme={null}
> #Preview {
>     CometChatFlagMessage(message: TextMessage(receiverUid: "bob", text: "hi", receiverType: .user),
>                          store: CometChatFlagMessageStore(seeded: .loaded,
>                                                           reasons: FlagReasonItem.samples,
>                                                           selectedReasonID: "spam"))
> }
> ```
>
> A seeded store never fetches and never reports.

> [tab] UIKit
>
> Pass a `CometChatFlagMessageStore` with `set(store:)`.

### Subclassing

> [tab] SwiftUI
>
> `CometChatFlagMessage` is a `View` struct. Customise it with its parameters, slot modifiers
> and style.

> [tab] UIKit
>
> | Method | Called |
> | - | - |
> | `buildUI()` | once, in `viewDidLoad`, to build the scrim, the card and its contents |
> | `setupStyle()` | after `buildUI()`, and when `style` is set |
> | `showError(_:)` | to show or hide the error line |
> | `startReporting()`, `stopReporting()` | to put the spinner in **Report**'s place, and take it out |
>
> ```swift theme={null}
> final class ModeratorFlagMessage: CometChatFlagMessage {
>     override func buildUI() {
>         super.buildUI()
>         set(title: "Report to moderators")
>     }
>
>     override func setupStyle() {
>         super.setupStyle()
>         reportButton.backgroundColor = .systemRed
>     }
> }
> ```
>
> The views are public — `containerView`, `titleLabel`, `closeButton`, `subtitleLabel`,
> `collectionView`, `reasonTitleLabel`, `textView`, `placeholderLabel`, `cancelButton`,
> `reportButton`, `reportLoader` and `errorLabel` — and each chip is a `FlagMessageCell`.

### Objective-C

In the UIKit toolkit:

The dialog, `FlagMessageStyle` and the delegate are `@objc`. `set(reasons:)`,
`flagReasonLocalizer`, `set(store:)` and the closure setters are Swift-only — the SDK's
`FlagReason` and `FlagDetail` are not visible to Objective-C:

```objc theme={null}
CometChatFlagMessage *dialog = [[CometChatFlagMessage alloc] init];
[dialog setWithMessageId:42];
dialog.hideFlagRemarkFeild = YES;
FlagMessageStyle *style = [[FlagMessageStyle alloc] init];
style.reportButtonBackgroundColor = UIColor.systemRedColor;
dialog.style = style;
dialog.delegate = self;
```

***

## Accessibility

In the SwiftUI toolkit:

* The card reads as "Flag Message Dialog" and is modal: VoiceOver does not read the chat
  behind it. The X reads as "Close".
* Each chip is a button, marked selected when it is. **Report** keeps its label while the
  spinner shows.
* The error line is announced when it appears.

***

## Style

> [tab] SwiftUI
>
> `CometChatFlagMessageStyle` is sparse: set only what you change, and everything else
> follows the theme. `backgroundColor` and `borderRadius` apply only to the opaque card.
>
> ```swift theme={null}
> var style = CometChatFlagMessageStyle()
> style.chipActiveBackgroundColor = .orange.opacity(0.2)
> style.chipActiveBorderColor = .orange
> style.reportButtonEnabledBackgroundColor = .red
>
> CometChatFlagMessage(message: reportedMessage, style: style)
> ```
>
> | Property | Default |
> | - | - |
> | `backgroundColor`, `borderRadius` | `background1`, 18 — the opaque card only |
> | `strokeColor`, `strokeWidth` | `strokeDefault`, 0 |
> | `titleColor`, `titleTextStyle` | `textPrimary`, `heading2Bold` |
> | `subtitleColor`, `subtitleTextStyle` | `textSecondary`, `buttonRegular` |
> | `closeIconColor` | `iconTintPrimary` |
> | `chipActive…` / `chipInactive…` `BackgroundColor`, `TextColor`, `BorderColor` | `extendedPrimary100`, `textHighlight`, `extendedPrimary200` / `background1`, `textPrimary`, `strokeDefault` |
> | `chipCornerRadius`, `chipStrokeWidth`, `chipTextStyle` | 14, 1, `bodyRegular` |
> | `remarkFieldTitleTextColor`, `remarkFieldTitleTextStyle` | `textPrimary`, `buttonRegular` |
> | `remarkFieldHintTextColor`, `remarkFieldTextColor`, `remarkFieldTextStyle` | `textTertiary`, `textPrimary`, `buttonRegular` |
> | `remarkFieldBackgroundColor`, `remarkFieldStrokeColor` | `background2`, `strokeDefault` |
> | `buttonCornerRadius`, `buttonStrokeColor`, `buttonStrokeWidth` | 8, `strokeDark`, 0 |
> | `reportButtonEnabledBackgroundColor`, `reportButtonDisabledBackgroundColor` | `primary`, the enabled colour — drawn at 40 % |
> | `reportButtonEnabledTextColor`, `reportButtonDisabledTextColor`, `reportButtonTextStyle` | white, white, `buttonRegular` |
> | `cancelButtonEnabledBackgroundColor`, `cancelButtonEnabledTextColor`, `cancelButtonTextStyle` | clear, `textPrimary`, `buttonRegular` |
> | `errorTextColor`, `errorTextStyle` | `error`, `buttonRegular` |
> | `progressIndicatorColor` | white |
> | `scrimColor` | black at 40 % |
>
> `cancelButtonDisabledBackgroundColor` and `cancelButtonDisabledTextColor` have no effect:
> **Cancel** is never disabled.

> [tab] UIKit
>
> `backgroundColor` and `cornerRadius` style only the opaque card. Unset colours and fonts
> follow `CometChatUIKitTheme`.
>
> Set the default for every new dialog:
>
> ```swift theme={null}
> CometChatFlagMessage.style.reportButtonBackgroundColor = .systemRed
> CometChatFlagMessage.style.chipSelectedBorderColor = .systemRed
> ```
>
> Or style one dialog:
>
> ```swift theme={null}
> let style = FlagMessageStyle()
> style.titleTextColor = .label
> style.chipSelectedBackgroundColor = .systemRed.withAlphaComponent(0.1)
>
> let dialog = CometChatFlagMessage()
> dialog.set(style: style)
> ```
>
> | Property | Default |
> | - | - |
> | `titleTextFont`, `titleTextColor` | `heading2Bold`, `textPrimary` |
> | `subtitleTextFont`, `subtitleTextColor` | `buttonRegular`, `textSecondary` |
> | `reasonTitleTextFont`, `reasonTitleTextColor` | `buttonRegular`, `textPrimary` — "Reason (Optional)" |
> | `reasonTextFont`, `reasonTextColor` | `buttonRegular`, `textPrimary` — the remark |
> | `placeholderTextColor`, `textViewBackgroundColor`, `textViewBorderColor` | `textTertiary`, `background2`, `strokeDefault` |
> | `reportButtonBackgroundColor`, `reportButtonTintColor`, `reportButtonTextFont` | `primary`, white, `buttonRegular` |
> | `reportButtonDisabledBackgroundColor`, `reportButtonDisabledTintColor` | the enabled colour, white — drawn at 40 % |
> | `cancelButtonBackgroundColor`, `cancelButtonTintColor`, `cancelButtonTextFont` | clear, `textPrimary`, `buttonRegular` |
> | `buttonCornerRadius`, `buttonBorderColor`, `buttonBorderWidth` | 8, `strokeDark`, 0 |
> | `errorTColor`, `errorTextFont` | `error`, `buttonRegular` |
> | `backgroundColor`, `cornerRadius` | `background1`, 18 — the opaque card only |
> | `borderColor`, `borderWidth` | `strokeDefault`, 0 |
> | `closeIconTintColor`, `scrimColor` | `iconTintPrimary`, black at 40 % |
> | `chipBackgroundColor`, `chipTextColor`, `chipBorderColor` | `background1`, `textPrimary`, `strokeDefault` |
> | `chipSelectedBackgroundColor`, `chipSelectedTextColor`, `chipSelectedBorderColor` | `extendedPrimary100`, `textHighlight`, `extendedPrimary200` |
> | `chipTextFont`, `chipCornerRadius`, `chipBorderWidth` | `bodyRegular`, 14, 1 |
> | `progressIndicatorColor` | white |
>
> `cancelButtonDisabledBackgroundColor` and `cancelButtonDisabledTintColor` have no effect:
> **Cancel** is never disabled.

***

## Next Steps

> [card] [Message List](https://www.cometchat.com/docs/ui-kit/ios/v6/message-list.md)
>
> Presents the dialog from the Report option

> [card] [Theming](https://www.cometchat.com/docs/ui-kit/ios/v6/theming.md)
>
> The tokens the dialog's defaults come from


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.