Poll Post

To create a poll post, you need to create a poll first and then attach the newly created poll to a post. SDK keeps all poll-related APIs in AmityPollRepository obtained from AmitySocialClient.newPollRepository and provides a builder design pattern named AmityPollBuilder which can be obtained from pollRepository.createPoll(question: String) .

It allows you to create a poll with these inputs:

  • question - a question which can be up to 500 characters

  • answers - a set of two to ten answers. Each answer can be up to 200 characters.

  • answerType - indicator whether the poll allows multiple choices. Default type is AnswerType.SINGLE .

  • closedIn - a time window indicating how long this poll will take. By default, the closedIn value is set to 30 days if the user does not set a value for it.

Create a Poll

Follow createPollPost() funtion to create a poll post

Get a Poll

Once a poll post is created, you can obtain a poll id from post data and use it to get a hand on a poll object which can later be used to access answers for a voting API.

Follow getPollPost() function to get a poll post

Vote

This API allows you to vote only once and it cannot be undone. However, you can have multiple choices if the poll type is AnswerType.MULTIPLE.

Close a Poll

Only the owner/creator of a poll can close a poll before the closing time.

Follow votePoll() function to close a poll post

Delete a Poll

Only the owner/creator of a poll can delete a poll.

Follow deletePoll() function to delete a poll post.

Last updated