Skip to content

Cocos Creator quickstart

FRVR ships a Cocos Creator extension — a .zip that installs into Cocos Creator’s extension manager and exposes the SDK to your TypeScript game scripts via FRVRSDK.instance.*.

This quickstart covers the Cocos Creator 3.x extension (frvr-sdk-cocos-3.x.zip), targeting Cocos Creator 3.8.0 or newer, building for web‑mobile or web‑desktop. If you’re on Cocos Creator 2.4.x, download frvr-sdk-cocos-2.4.zip instead — it ships its own README; the install steps and API below don’t apply.

FRVR’s release pipeline picks up the web build and packages it per platform (Facebook Instant, iOS WebView, Android TWA, …).

Download frvr-sdk-cocos-3.x.zip from the Downloads page.

  1. Unzip the frvr-sdk/ folder into your project’s extensions/ directory.
  2. In Cocos Creator: Extension → Extension Manager → enable frvr-sdk.
  3. The runtime scripts install automatically into assets/frvr-sdk/.
  • First scene must have a node with the FRVRSDK component attached. The SDK will not initialize without it.
  • Build platform must be web‑mobile (or web‑desktop). Native / mobile Cocos exports aren’t supported.
import { FRVRSDK, AdShowResult } from './frvr-sdk/FRVRSDK';

If the FRVRSDK component has autoInit enabled in the Inspector, initialization happens for you. Otherwise:

await FRVRSDK.instance.initSDK();

if (FRVRSDK.instance.isReady) {
  // Safe to use any FRVRSDK.instance.* method
}

The component also handles your loading progress (autoTrackLoading), but you can drive it manually if you’d rather:

FRVRSDK.instance.setLoadingProgress(0.5);
// …
FRVRSDK.instance.completeLoading();

All calls are on the singleton FRVRSDK.instance.

if (FRVRSDK.instance.isRewardedReady()) {
  const result = await FRVRSDK.instance.showRewarded();
  if (result === AdShowResult.COMPLETED) giveReward();
}

if (FRVRSDK.instance.isInterstitialReady()) {
  await FRVRSDK.instance.showInterstitial();
}
FRVRSDK.instance.levelStart('level_1');
FRVRSDK.instance.levelEnd('level_1');

Same shape for both — batch APIs are preferred for performance:

await FRVRSDK.instance.localStorageSetItem('coins', 100);
const coins = await FRVRSDK.instance.localStorageGetItem('coins');
await FRVRSDK.instance.localStorageRemoveItem('coins');

await FRVRSDK.instance.localStorageSetItems([
  { key: 'score', value: 4200 },
  { key: 'level', value: 5 },
]);
const batch = await FRVRSDK.instance.localStorageGetItems(['score', 'level']);

Cloud variants: cloudStorageSetItem, cloudStorageGetItem, cloudStorageRemoveItem, cloudStorageSetItems, cloudStorageGetItems, cloudStorageRemoveItems. Identical call signatures.

const id    = await FRVRSDK.instance.getPlayerId();
const name  = await FRVRSDK.instance.getPlayerName();
const photo = await FRVRSDK.instance.getPlayerImage();
const png   = await FRVRSDK.instance.loadPlayerImage(photo); // base64 data URL

On Facebook Instant, name and photo may be undefined under Meta’s zero‑permissions model — use Shield overlays to render player info there.

if (FRVRSDK.instance.isSocialAPISupported('shareMessage')) {
  await FRVRSDK.instance.shareMessage({
    text:     'I hit 10,000!',
    headline: 'High Score',
    cta:      'Play Now',
  });
}

await FRVRSDK.instance.inviteUsers({
  text:     'Join me!',
  headline: 'Game Invite',
});

// FRVR friends
await FRVRSDK.instance.syncFriends();
const friends = await FRVRSDK.instance.getAllFriends();
await FRVRSDK.instance.addFriend(friendId);
import { SocialEvent } from './frvr-sdk/FRVRSDK';

FRVRSDK.instance.socialLiveConnect();

FRVRSDK.instance.socialLiveOn(SocialEvent.ON_FRIEND_STATUS_UPDATED, e => /* … */);
FRVRSDK.instance.socialLiveOn(SocialEvent.ON_GAME_INVITE,           e => /* … */);

FRVRSDK.instance.socialLiveSendGameInvite(userId, lobbyId, { level: 1 });
FRVRSDK.instance.socialLiveUpdateStatus({ level: 1 });

// Later
FRVRSDK.instance.socialLiveClose();
const id = await FRVRSDK.instance.createTournament(
  { gameMode: 'classic' },
  {
    title:     'Weekly Challenge',
    sortOrder: 'HIGHER_IS_BETTER',
    endTime:   Date.now() + 7 * 24 * 3600 * 1000,
  }
);
await FRVRSDK.instance.postTournamentScore(id, 1000);

if (FRVRSDK.instance.isPlatformTournamentsSupported()) {
  const current = await FRVRSDK.instance.getCurrentPlatformTournament();
}
if (!FRVRSDK.instance.isIAPReady()) return;

const catalog = FRVRSDK.instance.getIAPCatalog();
const product = FRVRSDK.instance.getIAPProduct('coins_100');

const purchase = await FRVRSDK.instance.purchase('coins_100', { meta: 'shop_click' });
if (purchase) {
  grantItem(purchase.productId);
  await FRVRSDK.instance.consumePurchase(purchase);
}

// Recover crashes mid-purchase on startup
const unconsumed = await FRVRSDK.instance.getUnconsumedPurchases();
for (const p of unconsumed) {
  grantItem(p.productId);
  await FRVRSDK.instance.consumePurchase(p);
}
if (await FRVRSDK.instance.canScheduleNotifications()) {
  await FRVRSDK.instance.subscribeNotifications();

  await FRVRSDK.instance.scheduleNotification({
    playerId:       await FRVRSDK.instance.getPlayerId(),
    delayInSeconds: 86400,
    imageUrl:       'https://cdn.mygame.com/push.png',
    message:        'Come back and play!',
    buttonTitle:    'Play Now',
  });
}
if (await FRVRSDK.instance.canCreateShortcut()) {
  await FRVRSDK.instance.createShortcut();
}

if (await FRVRSDK.instance.canMoveToMobile()) {
  await FRVRSDK.instance.moveToMobile();
}
const data = await FRVRSDK.instance.getEntrypointData();
const name = await FRVRSDK.instance.getEntrypointName();

if (data?.level) goToLevel(data.level);
if (FRVRSDK.instance.allowsExternalLinks()) openPrivacyPolicy();
if (FRVRSDK.instance.allowsNavigation())    pushLocation();

Build as web-mobile (or web-desktop). The extension auto‑injects the FRVR SDK scripts into index.html for dev. FRVR’s release pipeline handles per-platform packaging — you don’t pick a channel bundle.