Skip to main content

GetActivePollAsync

Gets the currently active poll for a specific Sensei persona.

Method Signature

public async Task<ActiveSenseiPollResponse?> GetActivePollAsync(string personaId)

Parameters

ParameterTypeDescription
personaIdstringThe ID of the persona to get the active poll for. You can find this in your PlaySafe Dashboard

Returns

Returns an ActiveSenseiPollResponse object containing the active poll information, or null if no active poll exists or the request failed.

Usage Example

string personaId = "your-persona-id"; // From PlaySafe Dashboard
var poll = await playSafeManager.GetActivePollAsync(personaId);

if (poll != null && poll.Ok && poll.Data != null)
{
Debug.Log($"Active poll question: {poll.Data.Question}");
Debug.Log($"Poll options: {string.Join(", ", poll.Data.Options)}");
Debug.Log($"Poll expires at: {poll.Data.ExpiresAt}");

// Use the poll ID for voting
string pollId = poll.Data.Id;
}

Response Type

ActiveSenseiPollResponse

public class ActiveSenseiPollResponse
{
public bool Ok { get; set; }
public ActiveSenseiPollData Data { get; set; }
public string Message { get; set; }
}

ActiveSenseiPollData

public class ActiveSenseiPollData
{
public string Id { get; set; }
public string Question { get; set; }
public List<string> Options { get; set; }
public string ExpiresAt { get; set; }
public string PersonaId { get; set; }
public string ProductId { get; set; }
public bool IsActive { get; set; }
}

Properties

PropertyTypeDescription
OkboolIndicates whether the request was successful
Data.IdstringUnique identifier for the poll
Data.QuestionstringThe poll question text
Data.OptionsList<string>Available response options
Data.ExpiresAtstringWhen the poll expires
Data.PersonaIdstringThe persona this poll belongs to
Data.ProductIdstringThe product this poll is associated with
Data.IsActiveboolWhether the poll is currently active
MessagestringResponse message from the server

Error Handling

The method returns null if:

  • Network request fails
  • No active poll exists for the persona
  • Response parsing fails

Always check for null and verify the Ok property before accessing the data.

Notes

  • Persona IDs can be found in your PlaySafe Dashboard
  • Only one poll can be active per persona at a time
  • Use the returned Id for voting with CastVoteAsync
  • Check the ExpiresAt property to ensure the poll is still valid