Introduction
The meetings polls object can be accessed using meeting.polls
. It provides
methods to create polls, vote, and more.
meeting.polls.items
returns an array of all polls created in a meeting, where
each element is an object of type Poll
.
class Poll {
let id: String
let question: String
let anonymous: Bool
let hideVotes: Bool
let createdBy: String
let options: [PollOption]
let voted: [String]
}
The type Poll
is the main class for any poll in RealtimeKit. It also
contains list of PollOption
which are options for a given poll. And every
PollOption
has list of votes inside of it. Votes are objects of class
PollVote
which internally has id and name of the vote.
class PollOption {
let text: String
let votes: [PollVote]
let count: Int
}
class PollVote {
let id: String
let name: String
}
One can easily create, vote and view polls by listening to callbacks on
meeting
object.
Listening to new polls in a meeting
To be able to receive new poll messages you need to implement a method
onPollUpdates()
method from callback RtkPollsEventListener
. You can
subscribe to this events by calling
meeting.addPollsEventListener(meetingViewModel)
extension MeetingViewModel: RtkPollsEventListener {
func onNewPoll(poll: Poll) {
// code to handle new poll
}
func onPollUpdates(pollItems: [Poll]) {
// code to handle polls and their vote updates.
}
func onPollUpdate(poll: Poll) {}
}