Poll

The Amity Social SDK encompasses comprehensive support for polls, offering developers an effortless way to incorporate polls into their social applications. Polls enable users to create and participate in a diverse range of topics, sparking targeted engagement and conversations among users.

To integrate poll functionality, developers can utilize the poll features offered by the Amity Social SDK in their applications. Polls can be tailored to meet specific needs, including options for single or multiple-choice polls, setting poll expiration dates, and more. Users can then participate in the poll by choosing their preferred option. At present, the Amity Social SDK only supports the integration of polls within posts, please refer to - #create-poll-post, Poll Post.

Create Poll

As demonstrated in the code sample below, here's a way to create a poll in the poll post.

Polls can be created with the following settable controls:

  • question - A question that can be up to 500 characters long.

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

  • answerType - Indicates whether the survey allows multiple choices. The available options are Single (default) and Multiple.

  • timeToClosePoll - A time window limiting how long the poll will be open. By default, the setTimeToClosePoll value is set to 30 days if no value has been set for it.

Vote Poll

This function enables you to cast a single vote and the vote cannot be revoked. If the poll type is multiple, you have the option to select multiple choices.

Here's an explanation of the method's parameters:

  • pollId: This is a required parameter of type String, which represents the ID of the poll that the user wants to vote on.

  • answerIds: This is a required parameter of type Array<String>, which represents an array of IDs of the answer options that the user wants to vote for. Users can select one or multiple answers depending on the poll's configuration.

Close Poll

The ability to close a poll is restricted exclusively to individuals who have ownership permissions, such as the creator of the poll or an administrator. It is important to note that a poll can only be closed prior to its designated closing time.

Here's an explanation of the method's parameter:

  • pollId: This is a required parameter of type String, which represents the ID of the poll that the user wants to close.

Delete Poll

The deletion of a poll is limited exclusively to individuals who possess ownership permissions, such as the creator of the poll or an administrator.

Here's an explanation of the method's parameter:

  • pollId: This is a required parameter of type String, which represents the ID of the poll that the user wants to delete.

Last updated