Skip to content

Social

FRVR.social manages the player’s friends and offers the channel’s native sharing surfaces (share sheet, invite picker, update notifications).

It has three layers:

  • FRVR.social — FRVR’s own friend graph, synced to the server. Cross‑channel, persistent.
  • FRVR.social.platform — direct access to the channel’s social UIs (Facebook friend picker, iOS share sheet, etc.).
  • FRVR.social.live — a WebSocket connection for real‑time presence and game invites between friends.

Requires auth.

// Upload the channel's friend list so FRVR can match and register them
await FRVR.social.syncFriends();

// Read the synced list (always the same shape across channels)
const { friends } = await FRVR.social.getAllFriends();

// Look up by FRVR id or by the channel's own id
const a = await FRVR.social.getFriendByFRVRID('frvr_123');
const b = await FRVR.social.getFriendByChannelId('fb_4567');

// Manually add/remove (e.g. from an invite code)
await FRVR.social.addFriend(targetFrvrId);
await FRVR.social.removeFriend(targetFrvrId);

Default config syncs friends automatically at login:

FRVR.config.social = {
  syncFriendsOnLogin: true,
};

When the host platform has a native share sheet or invite flow, go through platform. Each call resolves when the user finishes (or cancels) the interaction.

Always check getSupportedAPIs() before wiring a button — not every channel offers every surface.

const supported = FRVR.social.platform.getSupportedAPIs();
// → ['shareMessage', 'invite', …] — hide UI for what isn't supported

if (FRVR.social.platform.isSupportedAPI('invite')) {
  // …
}

Posts to the user’s timeline / story / share sheet, depending on the channel.

await FRVR.social.platform.shareMessage({
  image:    '/share/score.png',     // BASE64, JPEG, or PNG
  text:     'I hit 10,000 points!',
  headline: 'New high score',
  cta:      'Beat my score',
  entryPointData: { from: 'share', score: 10000 },
});
FieldTypeRequiredPurpose
imagestringyesImage data URL or hosted URL (BASE64 / JPEG / PNG).
textstringyesBody / description text.
headlinestringnoShort headline above the body, where the channel supports it.
ctastringnoCall‑to‑action button label.
entryPointDataobjectnoArbitrary payload delivered to the recipient via entry point when they open the share.

Opens the channel’s friend picker so the player can invite one or more contacts directly into the game.

if (await FRVR.social.platform.canInvite()) {
  await FRVR.social.platform.invite({
    image:    '/invite/banner.png',
    text:     'Come play with me!',
    headline: 'Join my game',
    cta:      'Play now',
    entryPointData: { from: 'invite', lobbyId: 'lobby_42' },
  });
}
FieldTypeRequiredPurpose
imagestringyesImage data URL or hosted URL (BASE64 / JPEG / PNG).
textstringyesMessage shown alongside the image.
headlinestringnoShort headline above the body, where the channel supports it.
ctastringnoCall‑to‑action button label.
entryPointDataobjectnoPayload available to the recipient through entry point on join.

canInvite() returns false on channels where invites are unavailable or the user is in a context where the host disallows them — gate your UI on it.

Yields control to the platform so it can deliver a templated update (Facebook context update, Snapchat sticker, Discord activity, …). Templates live in @frvr-social/defaultTemplatesConfig — drop the channel‑specific config into your game folder to use them.

await FRVR.social.platform.sendUpdate({
  template:       'JOIN_PLAYER',
  image:          '/update/lobby.png',
  bitmojiVariant: 'HAPPY',                    // snapchat only
  entryPointData: { lobbyId: 'lobby_42' },
});
FieldTypePurpose
templatestringPredefined template name (e.g. 'JOIN_PLAYER').
imagestringImage data URL or hosted URL (BASE64 / JPEG / PNG).
bitmojiVariantstringSnapchat bitmoji pose — 'HAPPY', 'WINK', 'HEARTEYES', etc. See SDK types for the full list.
entryPointDataobjectPayload delivered via entry point when the recipient opens the update.
overrideobjectChannel‑specific raw payloads (snapchat, facebookInstant, facebookRooms, discord) that replace the template fields.
const friends = await FRVR.social.platform.getFriends();
// → Friend[]: { id, name, nickname?, image, channel }

// Where the user currently is on the host (FB context, Snap chat, Discord activity, …)
const ctxId      = await FRVR.social.platform.getContextId();
const ctxData    = await FRVR.social.platform.getContextData();
const ctxPlayers = await FRVR.social.platform.getContextPlayers();

getFriends() returns friends who have played this game on the current channel — best‑effort, subject to each channel’s policies. For the cross‑channel FRVR graph use FRVR.social.getAllFriends() instead.

Social: supported APIs + share

loading SDK…
 

FRVR.social.live opens a WebSocket so you can react to friends coming online, exchange game invites, and broadcast your own status in real time. Requires auth.

const { live } = FRVR.social;

live.connect();

live.on(live.SocialEvents.onConnect, ({ data }) => {
  // data.friends: Status[]  — current presence snapshot for each friend
});

live.on(live.SocialEvents.onFriendStatusUpdated, ({ data }) => {
  // data: { userId, gameId, presence: 'online' | 'offline', metadata }
  if (data.presence === 'online') toast(`${data.userId} is online`);
});

live.on(live.SocialEvents.onGameInvite, ({ data }) => {
  // data: { recipientId, gameId, lobbyId }
  showInvitePrompt(data.lobbyId);
});

live.on(live.SocialEvents.onError, ({ data }) => {
  console.warn('social live error', data.message);
});
// Tell friends what you're doing — show up in their onFriendStatusUpdated
live.updateStatus({ inLobby: 'lobby_42', mode: 'co-op' });

// Direct invite to a specific friend
live.sendGameInvite('frvr_123', 'lobby_42', { mode: 'co-op' });
const status = live.getFriendsStatus();   // Status[] — last‑known presence for each friend
live.close();

The connection is closed automatically on logout.

MethodPurpose
syncFriends()Push the channel’s friend list to FRVR; matches and registers friends with FRVR ids.
getAllFriends()Read the synced cross‑channel friend list.
getFriendByFRVRID(frvrId)Look up a synced friend by FRVR id.
getFriendByChannelId(channelId)Look up a synced friend by their channel‑native id.
addFriend(frvrId) / removeFriend(frvrId)Manual graph edits.
MethodPurpose
shareMessage(config)Open the channel’s share sheet with image + text.
invite(config) / canInvite()Open the channel’s friend invite picker, gated on support.
sendUpdate(config)Templated platform update (FB context update, Snap sticker, …).
getFriends()Friends on the current channel who play this game.
getContextId() / getContextData() / getContextPlayers()The current host context (chat, room, party).
getSupportedAPIs() / isSupportedAPI(api)Feature detection — gate UI on the result.
Method / EventPurpose
connect() / close()Open or close the WebSocket. Reconnects on auth refresh.
on(event, cb)Subscribe to onConnect, onFriendStatusUpdated, onGameInvite, onError.
updateStatus(metadata)Broadcast your own presence metadata to friends.
sendGameInvite(recipientId, lobbyId, metadata?)Push a direct invite to a friend’s onGameInvite.
getFriendsStatus()Last‑known presence snapshot for each friend.