CometChatCreatePoll is the form for a new poll: a question and its options. The
message composer opens it from its Poll attachment
option and posts the poll for you. You can also host it yourself.
The form is not a connected component. It makes no network call: it hands the question and
options back when Send is tapped, and its host creates the poll and tells it how that went.

Where It Fits
- SwiftUI
- UIKit
CometChatCreatePoll is a View.Quick Start
With the Composer
The composer’s Poll option is hidden by default. Show it and the composer does the rest.- SwiftUI
- UIKit
onError.The option is dropped inside a thread (see the composer’s
menu caveat).Host It Yourself
Handle the submit callback, post the poll, and tell the form how it went. The composer’s store has the call it uses.- SwiftUI
- UIKit
Handle
onSubmitClick, post the poll, and pass isSubmitting and errorMessage back in.createPoll posts to the store’s current user or group. With neither set, it fails with
ERR_NO_RECEIVER.The Form
- SwiftUI
- UIKit
The form has a navigation bar with Cancel, the title and Send, then a Question
section and a Set the answers section. The form takes no focus by itself.

- The question is multi-line. Each option is a single line.
- Two option rows to start. When both are filled, a third appears. From then on, typing in the last row adds another, up to 12. At 12 there is no empty row.
- Removing: there is no delete button. An empty row is removed when it loses focus, unless it is the last row or only two rows are left. A row of spaces counts as blank and is removed.
- Reordering: long-press a filled row and drag it onto another filled row. The drag handle shows on filled rows only.
- The form scrolls to the bottom whenever rows are added or removed.
- A row’s focus belongs to its position, not its content. When an empty row loses focus to
the row below it and is removed, the focus moves to the next row down. For example,
tapping D in
A, (empty), C, D, (empty)leaves the caret in the last, empty row.
onSubmitClick receives the question, trimmed, and one entry per row at the row’s
index: the row’s text, trimmed, or nil for a blank row. So A, blank, C arrives as
["A", nil, "C"] — and the composer posts it that way, as a JSON null between the two
options.Actions and Events
Callback Methods
- SwiftUI
- UIKit
Functionality
- SwiftUI
- UIKit
Advanced Methods
- SwiftUI
- UIKit
CometChatCreatePoll is a View struct. Customise it with its parameters and style.Accessibility
In the SwiftUI toolkit:- The question, each option and each drag handle have VoiceOver labels. Send says whether it is disabled.
- The “Creating Poll…” alert has its own VoiceOver label.
Style
- SwiftUI
- UIKit
CometChatCreatePollStyle is sparse: set only what you change, and everything else follows
the theme.Next Steps
Message Composer
Hosts this form behind the Poll option
Sticker Keyboard
The composer’s other hosted component
