Tournaments are timed competitive events with a shared starting payload and a shared leaderboard.
The Cocos wrapper exposes both FRVR tournaments (server‑backed, portable) and platform tournaments (host‑channel native, e.g. Facebook Instant’s tournaments surface).
const tournamentId = await FRVRSDK.instance.createTournament(
{ gameMode: 'classic' }, // payload — every participant gets this
{
title: 'Weekly Challenge',
sortOrder: 'HIGHER_IS_BETTER', // or 'LOWER_IS_BETTER' for time trials
endTime: Date.now() + 7 * 24 * 3600 * 1000,
},
);
await FRVRSDK.instance.postTournamentScore(tournamentId, 1000);
const tournament = await FRVRSDK.instance.getTournamentById(tournamentId);
const myEntry = await FRVRSDK.instance.getMyTournamentEntry(tournamentId);
const mine = await FRVRSDK.instance.getMyTournaments();
Some channels (Facebook Instant especially) have native tournament flows that surface in the host UI. If supported, prefer these — they get extra distribution from the platform.
if (FRVRSDK.instance.isPlatformTournamentsSupported()) {
const current = await FRVRSDK.instance.getCurrentPlatformTournament();
const active = await FRVRSDK.instance.getActivePlatformTournaments();
await FRVRSDK.instance.joinPlatformTournament(tournamentId);
await FRVRSDK.instance.leavePlatformTournament();
await FRVRSDK.instance.sharePlatformTournament(score, payload);
}
sharePlatformTournament posts a tournament result to the channel’s feed/share surface — use it at the end of a run to drive virality.
async onRunEnded(score: number) {
if (FRVRSDK.instance.isPlatformTournamentsSupported()) {
const current = await FRVRSDK.instance.getCurrentPlatformTournament();
if (current) {
await FRVRSDK.instance.sharePlatformTournament(score, {});
return;
}
}
// Fallback: post to the current FRVR tournament if the player is in one
const mine = await FRVRSDK.instance.getMyTournaments();
const active = mine.find(t => !t.ended);
if (active) await FRVRSDK.instance.postTournamentScore(active.id, score);
}