본문으로 건너뛰기

Introduction

The meetings polls object can be accessed using meeting.polls. It provides methods to create polls, vote, and more.

meeting.polls.polls returns an array of all polls created in a meeting, where each element is an object of type DytePollMessage.

class DytePollMessage{
let id: String
let question: String
let anonymous: Bool
let hideVotes: Bool
let createdBy: String
let options: [DytePollOption]
}

The type DytePollMessage is the main class for any poll in Dyte. It also contains list of DytePollOption which are options for a given poll. And every DytePollOption has list of votes inside of it. Votes are objects of class DytePollVote which internally has id and name of the vote.

class DytePollOption{
let text: String
let votes: [DytePollVote]
let count: Int
}

class DytePollVote{
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 DyteMeetingRoomEventsListener. You can subscribe to this events by calling meeting.addMeetingEventsListener(meetingViewModel)

extension MeetingViewModel: DyteMeetingRoomEventsListener {
func onNewPoll(poll: DytePollMessage) {
// code to handle new poll
}

func onPollUpdates(pollMessages: [DytePollMessage]) {
// code to handle polls and their vote updates.
}
}