Quest session
The object startQuest returns. It tracks the timer, the question and the completion of one quest.
On this page
Members
| Member | Type | Meaning |
|---|---|---|
| questId | number | The quest this session belongs to. |
| displayDuration | number | Seconds the quest must be shown or watched. |
| deliveryToken | string | undefined | Token from the start, sent back when you complete. |
Timing
Returns the current state of the session.
getState(): QuestSessionStateReturns: A QuestSessionState.
Subscribes to timer progress. Unsubscribe when the view unmounts.
onProgress(callback: (progress: QuestSessionProgress) => void): () => void| Parameter | Type | Description |
|---|---|---|
callback required | (progress) => void | Called with { elapsed, total, percent, isComplete }. |
Returns: A function that removes the listener.
Feeds real video playback into the session. Use it with mediaDriven: true.
syncMediaProgress(elapsed: number, total: number): void| Parameter | Type | Description |
|---|---|---|
elapsed required | number | Seconds played. |
total required | number | Total seconds. |
Returns: Nothing.
Marks the timer as finished.
completeDuration(): voidReturns: Nothing.
Resolves when the required watch time has passed.
waitForDuration(): Promise<void>Returns: A Promise that resolves when the timer is done.
Questions and completion
Records a real click on the quest’s media.
registerClick(): Promise<void>Returns: A Promise that resolves when the click is recorded.
Loads the question for a video, banner or survey quest.
getQuestion(): Promise<QuestQuestion>Returns: A Promise of QuestQuestion.
Loads every question of a survey.
getQuestions(): Promise<QuestQuestion[]>Returns: A Promise of QuestQuestion[].
Submits the participant’s answer. Never choose the answer for them.
complete(answer?: string | number | SurveyAnswerInput[]): Promise<QuestCompleteResult>| Parameter | Type | Description |
|---|---|---|
answer | string | number | SurveyAnswerInput[] | The chosen option ID, or the answers of a multi-question survey. |
Returns: A Promise of { status, questId, completedAt?, reason?, rejectionCode?, settlementStatus, tokensAwarded?, tokenReward? }.
Submits evidence for a quest that is checked by review.
submitReview(evidence: string): Promise<QuestCompleteResult>| Parameter | Type | Description |
|---|---|---|
evidence required | string | The evidence the quest asks for. |
Returns: A Promise of QuestCompleteResult.
Growth quests
The session also exposes ingestEvent, getGrowthStatus, getStreakStatus, getCustomStatus and attributeReferral for the quest it was started for. They take the same arguments as the client methods, without the quest ID.