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 provides necessary methods to create a poll in AmityPollRepository class.

You can create a poll with the following inputs:

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

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

  • setAnswerType - indicates whether the survey allows multiple choices. The default type is AnswerType.SINGLE

    The available options are AnswerType.SINGLE and AnswerType.MULTIPLE. You can select either one or more than one option.

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

Create Poll

Finally, create the poll post:

Get Poll Data

After the poll post is created, you can access poll data using getPollInfo from AmityPost. This provides poll information attached to the post.

Vote Poll

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

Close Poll

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

Last updated