Skip to content

Challenges

A challenge is tournaments’ little sibling: you pick one or more specific opponents and send them a payload (seed, level, starting config). They play, you compare scores. Perfect for “beat my score” messages.

const challengeId = await FRVR.challenges.create(
  { title: '⚡ Beat my 42k!', endTime: Date.now() + 24 * 3600e3, image: '/challenge.png' },
  { seed: 12345, mode: 'blitz' },       // payload — both players get it
);

Returns the challenge ID, or undefined if the user picks “tournament” from the channel’s native dialog instead of creating the challenge.

If you already have a context ID (e.g. from an earlier play session) or a known FRVR player ID:

const challengeId = await FRVR.challenges.challengeByContextId(contextId, config, payload);
const challengeId = await FRVR.challenges.challengeByPlayerId(playerId, config, payload);

Channels that know about the player’s recent contacts can offer them:

const candidates = await FRVR.challenges.getPossibleOpponents();
// [{ id, name, photo, last_played_at }, …]

Typical on Facebook (friends active in the last 90 days), empty on sandboxed channels.

When a player arrives via a challenge invite (check entry point first), fetch it:

const challenge = await FRVR.challenges.getCurrentChallenge();
if (challenge) game.startWithPayload(challenge.payload);