GetActivePollAsync
Gets the currently active poll for a specific Sensei persona.
Method Signature
public async Task<ActiveSenseiPollResponse?> GetActivePollAsync(string personaId)
Parameters
Parameter | Type | Description |
---|---|---|
personaId | string | The 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
Property | Type | Description |
---|---|---|
Ok | bool | Indicates whether the request was successful |
Data.Id | string | Unique identifier for the poll |
Data.Question | string | The poll question text |
Data.Options | List<string> | Available response options |
Data.ExpiresAt | string | When the poll expires |
Data.PersonaId | string | The persona this poll belongs to |
Data.ProductId | string | The product this poll is associated with |
Data.IsActive | bool | Whether the poll is currently active |
Message | string | Response 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 withCastVoteAsync
- Check the
ExpiresAt
property to ensure the poll is still valid