/ SDKs / iOS
SDKs
Chat SDKs iOS v4
Chat SDKs iOS
Chat SDKs
iOS
Version 4

Close a poll

Copy link

You can close a poll by specifying the pollId in the closePoll() method.

channel.closePoll(pollId: poll.pollId) { poll, error in
    // A poll has been successfully closed.
}

The closeAt property

Copy link

When integrating polls in your application, managing the closeAt property is crucial for a smooth user experience. Here are guidelines for handling this property effectively:

1. Message list (Channel view)

Copy link
  • Closed polls: When rendering a list of messages, check if the poll's closeAt time is in the past compared to the current time. If it is, display the poll using a "closed" UI state. Note that differences between device and server time might affect this comparison.

2. Real-time updates in channels

Copy link
  • Active channel scenario: If a user is already in a chanel and remains in a channel past the closeAt time, implement a real-time timer to check closeAt against the current time and update the UI accordingly.

3. Re-entering a channel

Copy link
  • UI update on re-entry: Make sure the UI updates correctly to show the poll's closed state if closeAt has passed while the user was away in another view.

4. User interactions with closed polls

Copy link
  • Error handling: Prevent users from interacting with closed polls by updating the UI and handling errors appropriately if they attempt to vote after closeAt.

5. Standalone poll screens

Copy link
  • Consistent logic: Apply the same real-time checks and UI updates in standalone poll views as in message lists.