Skip to content

Class: PollService ​

Service for Kappapps native polls: platform-independent polls with live tallies, chat voting (parsed server-side, independently of any app or overlay) and in-app voting, plus an optional native on-screen display.

Remarks ​

Accessible everywhere via k.poll. You never have to instantiate this service yourself — it is created by the SDK when the app/widget starts. Only one poll can be active at a time on a channel.

The backend keeps collecting native votes after this execution ends. Live events and controls target the current pilot execution; the owner installation can take over with resume(id). The streamer retains dashboard control.

Example ​

ts
const poll = await k.poll.start({
    title: 'Next map?',
    choices: ['Dust II', 'Mirage', 'Inferno'],
    duration: 90
});
poll.onEnd(ended => {
    console.log('Results:', ended.data?.results);
});

See ​

PredictionService for predictions with currency bets.

Implements ​

Constructors ​

Constructor ​

ts
new PollService(): PollService;

Returns ​

PollService

Methods ​

get() ​

ts
get(id): Promise<Poll>;

Read an existing poll, including final state, without transferring control.

Parameters ​

id ​

number

Returns ​

Promise<Poll>


getActive() ​

ts
getActive(): Promise<PollData>;

Retrieves the channel's currently active poll, if any.

Returns ​

Promise<PollData>

The active poll data (PollData), or null when no poll is running.

Remarks ​

Read-only: this is how an app observes a poll started by another app execution (events and control are reserved to the emitter). Use resume(id) from the owner installation after restart.


resume() ​

ts
resume(id): Promise<Poll>;

Resume this installation's running poll; keeps all participations and deadlines.

Parameters ​

id ​

number

Returns ​

Promise<Poll>


start() ​

ts
start(poll): Promise<Poll>;

Creates and starts a poll on the channel.

Parameters ​

poll ​

PollCreateData

The poll creation data (PollCreateData).

Returns ​

Promise<Poll>

The created Poll, already active; listen to its progress / end events or close it via its own methods.

Example ​

ts
const poll = await k.poll.start({
    title: 'Best snack?',
    choices: ['Pizza', 'Tacos'],
    duration: 60,
    show_display: false // the app renders its own UI
});